home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / utilities / system / intuition / shadow / docs / shadowlibraryfuncs.doc < prev    next >
Encoding:
Text File  |  1995-03-17  |  100.6 KB  |  3,564 lines

  1.                        Shadow.library  Documentation
  2.                             Library Version 4.6
  3.  
  4.                               By David Navas
  5.                          Updated:  05 Feb 1992
  6.  
  7.                       Copyright © 1992 by David Navas
  8.                             All Rights Reserved
  9.  
  10. NAME
  11.       AddAttributes -- Create the attribute table for a class.
  12.  
  13. SYNOPSIS
  14.       result = AddAttributes( class, tags, num, offset )
  15.         d0                      a0    a1   d0     d1
  16.  
  17. FUNCTION
  18.       This function creates the array of Attribute structures that are
  19.       described both by the tags and by the superclass of the passed
  20.       class.
  21.  
  22.       Note that the array of Attributes, as stored in the class'
  23.       AttributeTable, includes all of the attributes, both as described
  24.       in the tags, AND as described in the superclass.  If you're
  25.       looking for an attribute description, you don't need to look at
  26.       any superclass to find it.
  27.  
  28.       It is unfortunate that, unlike METHODs, attributes defined in the
  29.       superclass have to copied to all subclasses.  In reality, only
  30.       the WATCHED attributes NEED to be copied, however this
  31.       involves an increased level of complexity which has yet to be
  32.       implemented, and so it remains -- 16bytes per attribute.... sigh.
  33.  
  34.       There are some benefits, however.  Multiple inheritence of
  35.       attributes is easy.  It's unimplemented, but it's a hop-skip-jump
  36.       away....
  37.  
  38.       After forming the AttibuteTable, the attributes are qsort'ed by the
  39.       attribute name, for fast attribute lookup.  Note that this is a
  40.       sorting by the System String's address, not by the string's value.
  41.  
  42.  
  43. INPUTS
  44.       META                 class; - the new class for which to build an
  45.                                      AttributeTable.
  46.                                     Function returns NULL if NULL class is
  47.                                      passed.
  48.       ATTRIBUTE_TAG        tags[]; - the (optional) new atributes to
  49.                                      include.
  50.       long                   num; - the number of additional attributes
  51.                                      from the class' superClass -- as
  52.                                      returned by PrepareAttrTags().
  53.       ULONG               offset; - the offset at which the next attribute
  54.                                      will reside.  This is usually the
  55.                                      size of the class' superClass.
  56.  
  57. OUTPUTS
  58.       long                result; - result code (should be a BOOL, oh well.)
  59.  
  60.       Specifies whether the AttributeTable was successfully built.  NULL
  61.       indicates an error.
  62.  
  63. RESULT
  64.       The specified class' AttributeTable is initialized.
  65.  
  66. BUGS
  67.       none known.
  68.  
  69. NOTES
  70.       Attributes are guaranteed to be arranged according to the order in
  71.       which they are specified in the tags[].  This allows you to build
  72.       a fixed structure over several attributes, or even over the whole
  73.       object definition.  [Internally this is done for all of the classes,
  74.       with the possible exception of the DIRECTORCLASS.]
  75.  
  76. SEE ALSO
  77.       PrepareAttrTags()
  78.       CopyDefaultAttributes()
  79.       FreeAttributes()
  80.       FindAttribute()
  81.       FindAttrDefn()
  82.  
  83. NAME
  84.       AddAutoResource -- Adds an automatically freed resource to a process.
  85.  
  86. SYNOPSIS
  87.       result = AddAutoResource( task, resource, key)
  88.         d0                       a0      d0     a1
  89.  
  90. FUNCTION
  91.       This function adds the specified resource to the optionally
  92.       specified task (defaults to current task) using the specified
  93.       key.
  94.  
  95.       These resources are kept on the PROCESSCLASS' ATTR_RESOURCETREE,
  96.       and are automatically freed (via a METHOD_META_REMOVE, and a
  97.       DropObject() when the Tree itself is freed) whenever:
  98.          a) The process receives a METHOD_META_REMOVE
  99.          b) The process receives a METHOD_META_DESTROY
  100.          c) A program inside of RemoveCurrentProgram() receives a ^C.
  101.          d) RemoveThread() is about to return.
  102.  
  103.       It is important to note that the resource is TRANSFERRED to the
  104.       ATTR_RESOURCETREE.  So you no longer own an object pointer to the
  105.       resource you passed to AddAutoResource().
  106.  
  107.       Ff this is a problem you can do:
  108.          AddAutoResource(NULL, UseObject(resource), MYNAME)
  109.          .
  110.          .
  111.          <code referencing resource>
  112.          .
  113.          .
  114.          DropObject(resource)
  115.  
  116.          <continue processing, no longer have pointer to resource>
  117.          .
  118.          .
  119.  
  120. INPUTS
  121.       OBJECT                 task; - The optional task object that performs
  122.                                       the auto-tracking.  If not specified,
  123.                                       assumes current taskObject.
  124.       OBJECT             resource; - The object to auto-track.
  125.       char                   *key; - The name of the resource.  Resources
  126.                                       without names (key == NULL) are stored
  127.                                       by their addresses.  Name addresses of
  128.                                       0-255 are reserved for priority freeing.
  129.                                       Resources are freed in INCREASING
  130.                                       key order.  Obviously, you can't
  131.                                       use AddAutoResource() to add a
  132.                                       resource at priority zero, as then the
  133.                                       resource would be added at the address
  134.                                       of the resource (NULL == 0).
  135.  
  136.  
  137. OUTPUTS
  138.       BOOL                result; - result code
  139.  
  140.       Specifies whether the resource was added correctly.  If it was not,
  141.       the resource is sent a METHOD_META_REMOVE, is dropped, and a FALSE
  142.       value is returned to indicate an error.
  143.  
  144.       If the resource was NULL, then this function returns FALSE
  145.  
  146.       Otherwise returns TRUE
  147.  
  148. RESULT
  149.       The resource is now auto-tracked by the indicated process.
  150.  
  151. BUGS
  152.       none known.
  153.  
  154. NOTES
  155.  
  156. SEE ALSO
  157.       RemoveAutoResource()
  158.       DropObject()
  159.       UseObject()
  160.  
  161. NAME
  162.       AddClassWatcher -- Adds a watcher to the given class.
  163.  
  164. SYNOPSIS
  165.       result = AddClassWatcher( watchName, director, pri, name, class )
  166.         d0                          a0        a1      d2   d0     d1
  167.  
  168. FUNCTION
  169.       This function will add the director to the class' attribute's
  170.       watching SList at the given priority with the given name.
  171.  
  172.       This is a low-level function.  You should use the provided
  173.       DIRECTORCLASS methods instead and ask specifically for a
  174.       class watcher.  Example is in browser.c -- GlobalDirector....
  175.       Or see the inluded ShadowLibMethods.doc for more details
  176.  
  177.  
  178. INPUTS
  179.       char             *watchName; - the attribute name to watch
  180.       OBJECT             director; - the director to add to the attribute
  181.                                       watching SList.
  182.       long                    pri; - the priority to add the watcher as.
  183.       char                  *name; - the name of the watcher.
  184.       META                  class; - the class to add the watcher to.
  185.  
  186.  
  187. OUTPUTS
  188.       BOOL result; - result code
  189.  
  190.       The result code is a boolean indicating the success or failure of
  191.       the function call.  A zero value indicates that an error occured.
  192.  
  193.  
  194. RESULT
  195.       The director is added to the class' watch list.
  196.  
  197. BUGS
  198.       none known.
  199.  
  200. NOTES
  201.  
  202. SEE ALSO
  203.       AddWatcherNode()
  204.       RemoveWatcherNode()
  205.       RemoveClassWatcher()
  206.  
  207. NAME
  208.       AddMethods -- initializes a class' method table
  209.  
  210. SYNOPSIS
  211.       result = AddMethods( class, tags )
  212.         d0                   a0    a1
  213.  
  214. FUNCTION
  215.       This function creates the array of MethodHandler structures that are
  216.       described both by the tags.
  217.  
  218.       Note that the array of MethodHandlers, as stored in the class'
  219.       MethodTable, includes only those methods described in the tags
  220.       field.  Unlike attributes, the superclass' methods are NOT
  221.       copied down to the newly defined class.
  222.  
  223.       While creating the MethodHandlers, the passed procObject and
  224.       defnObject are UseObject()'d, ensuring that the destination process
  225.       and the defining process hang around until the class referencing the
  226.       methods goes away.
  227.  
  228.       After forming the MethodTable, the methods are qsort'ed by the
  229.       method name, for fast method lookup.  Note that this is a
  230.       sorting by the System String's address, not by the string's value.
  231.  
  232.  
  233. INPUTS
  234.       META              class; - required class to add the methods to.
  235.       METHOD_TAG       tags[]; - the (optional and NULL-terminated) array
  236.                                  of MethodTag elements.
  237.  
  238. OUTPUTS
  239.       int result; - result code
  240.  
  241.       The result code is an integer indicating the success or failure of
  242.       the function call.  A zero value indicates that an error occured.
  243.  
  244.  
  245. RESULT
  246.       The class' verbs field is initialized.
  247.  
  248. BUGS
  249.       none known.
  250.  
  251. NOTES
  252.  
  253. SEE ALSO
  254.       DJM()                            DoJazzMethod()
  255.       InvalidateCache()
  256.       SetMethodArgs()
  257.       DestroyMethodTable()
  258.       FindMethodHandle()
  259.       BlockMethod()
  260.       RemoveAllPatches()
  261.       SetupMethodTags()
  262.  
  263. NAME
  264.       AddNodeBinTree    -- adds an object into  binary tree.
  265.  
  266. SYNOPSIS
  267.       result = AddNodeBinTree( bt, object, key)
  268.         d0                     a0    a1    d0
  269.  
  270. FUNCTION
  271.       This function will add the object into the binary tree sorted on
  272.       the key provided.
  273.  
  274.       The object is Used() by the UseObject() call when successfully
  275.       placed in the binary tree.
  276.  
  277.       Any number of objects may exist in any number of binary trees.
  278.       There is no restriction on how many trees an object can be
  279.       placed, nor in how many times an object can reside in a binary
  280.       tree (as there is on Exec lists).
  281.  
  282.       In addition, unlike many AVLTree implementation, objects
  283.       inserted with the same key are handled correctly.
  284.  
  285.  
  286. INPUTS
  287.       AVLTREE               *bt; - a pointer to the root of the binary tree.
  288.       OBJECT             object; - the object to add into the tree.
  289.       ULONG                 key; - the key value to insert on.
  290.  
  291. OUTPUTS
  292.       BOOL result; - result code
  293.  
  294.       zero on failure.  (Couldn't allocate binary node)
  295.  
  296.  
  297. RESULT
  298.       Object is added into binary tree.
  299.  
  300. BUGS
  301.       NOne known.
  302.  
  303. NOTES
  304.       Uses AVL trees.  Do not depend on order of insertion
  305.       on duplicate keys.  (Duplicate keys do work, though.)
  306.  
  307.       Remember that the keys are sorted unsigned, not signed.
  308.  
  309. SEE ALSO
  310.       UseObject()
  311.  
  312.       AddNodeStringBinTree()     AddNodeWatchedBinTree()
  313.       FindBinNode()              AddNodeStringWatchedBinTree()
  314.       FreeAllNodesBinTree()      RemoveWatchedBinNode()
  315.       RecurseBinTree()           RemoveStringWatchedBinNode()
  316.       RemoveBinNode()
  317.       RemoveStringBinNode()
  318.  
  319. NAME
  320.       AddNodeStringBinTree -- add an object to an AVLTREE keyed on a string.
  321.  
  322. SYNOPSIS
  323.       result = AddNodeStringBinTree( bt, object, name )
  324.         d0                           a0    a1     d1
  325.  
  326. FUNCTION
  327.       This function will add the object into the binary tree sorted on
  328.       the name provided.
  329.  
  330.       The object is Used by the UseObject() call when successfully placed
  331.       in the binary tree.
  332.  
  333.       The name uses the UseString and DropString conventions
  334.       for system strings.  The address of that string then
  335.       determines the order the binary tree is sorted in.  It
  336.       is NOT sorted by the string itself, sorry.
  337.  
  338.  
  339. INPUTS
  340.       AVLTREE               *bt; - a pointer to the root of the binary tree.
  341.       OBJECT             object; - the object to add into the tree.
  342.       char                *name; - the name to insert on.
  343.  
  344. OUTPUTS
  345.       BOOL result; - result code
  346.  
  347.       zero on failure.  (Couldn't allocate binary node, or system string)
  348.  
  349.  
  350. RESULT
  351.       The object is added into the binary tree sorted on the address of
  352.       the system string that is uniquely created on the passed name.
  353.  
  354. BUGS
  355.       none known.
  356.  
  357. NOTES
  358.       Yes, the third parameter is d1, not d0
  359.  
  360.       No, the binary tree is not sorted on the actual string, but on the
  361.       address of the associated system string.
  362.  
  363. SEE ALSO
  364.       UseObject()
  365.       DropString()/UseString()
  366.  
  367.       AddNodeBinTree()           AddNodeWatchedBinTree()
  368.       FindBinNode()              AddNodeStringWatchedBinTree()
  369.       FreeAllNodesBinTree()      RemoveWatchedBinNode()
  370.       RecurseBinTree()           RemoveStringWatchedBinNode()
  371.       RemoveBinNode()
  372.       RemoveStringBinNode()
  373.  
  374. NAME
  375.       AddNodeStringWatchedBinTree -- add an object to a watched AVLTREE,
  376.                                       keyed on a string.
  377.  
  378. SYNOPSIS
  379.       result = AddNodeStringWatchedBinTree( bt, object, name )
  380.         d0                                  a0    a1     d0
  381.  
  382. FUNCTION
  383.       This function will add the object into the watched binary tree
  384.       sorted on the name provided.
  385.  
  386.       The object is Used by the UseObject() call when successfully placed
  387.       in the binary tree.
  388.  
  389.       The name uses the UseString and DropString conventions
  390.       for system strings.  The address of that string then
  391.       determines the order the binary tree is sorted in.  It
  392.       is NOT sorted by the string itself, sorry.
  393.  
  394.       If any parties are interested, WatcherDispatch is called with
  395.       W_INSERT_NODE for the flag parameter.
  396.  
  397.  
  398. INPUTS
  399.       W_AVLTREE              bt; - a pointer to the root of the watched
  400.                                     binary tree.
  401.       OBJECT             object; - the object to add into the tree.
  402.       char                *name; - the name to insert on.
  403.  
  404. OUTPUTS
  405.       BOOL result; - result code
  406.  
  407.       zero on failure.  (Couldn't allocate binary node, or system string)
  408.  
  409.  
  410. RESULT
  411.       The object is added into the binary tree sorted on the address of
  412.       the system string that is uniquely created on the passed name.
  413.  
  414. BUGS
  415.       none known.
  416.  
  417. NOTES
  418.       No, the binary tree is not sorted on the actual string, but on the
  419.       address of the associated system string.
  420.  
  421. SEE ALSO
  422.       UseObject()
  423.       DropString()/UseString()
  424.  
  425.       AddNodeBinTree()           AddNodeWatchedBinTree()
  426.       AddNodeStringWatchedBinTree()
  427.       FindBinNode()
  428.       FreeAllNodesBinTree()
  429.       RecurseBinTree()
  430.       RemoveBinNode()            RemoveWatchedBinNode()
  431.       RemoveStringBinNode()      RemoveStringWatchedBinNode()
  432.  
  433. NAME
  434.       AddNodeWatchedBinTree    -- adds an object into watched binary tree
  435.  
  436. SYNOPSIS
  437.       result = AddNodeWatchedBinTree( bt, object, key)
  438.         d0                            a0    a1    d0
  439.  
  440. FUNCTION
  441.       This function will add the object into the watched binary tree
  442.       sorted on the key provided.
  443.  
  444.       The object is Used() by the UseObject() call when successfully
  445.       placed in the binary tree.
  446.  
  447.       Any number of objects may exist in any number of binary trees.
  448.       There is no restriction on how many trees an object can be
  449.       placed (as there is on Exec lists).
  450.  
  451.       If any parties are interested, WatcherDispatch is called with
  452.       W_INSERT_NODE for the flag parameter.
  453.  
  454.  
  455. INPUTS
  456.       W_AVLTREE              bt; - a pointer to the root of the watched
  457.                                     binary tree.
  458.       OBJECT             object; - the object to add into the tree.
  459.       ULONG                 key; - the key value to insert on.
  460.  
  461. OUTPUTS
  462.       BOOL result; - result code
  463.  
  464.       zero on failure.  (Couldn't allocate binary node)
  465.  
  466.  
  467. RESULT
  468.       Object is added into binary tree.
  469.  
  470. BUGS
  471.       none known.
  472.  
  473. NOTES
  474.       Uses AVL trees.  Do not depend on order of insertion
  475.       on duplicate keys.  (Duplicate keys do work, though.)
  476.  
  477.       Remember that the keys are sorted unsigned, not signed.
  478.  
  479. SEE ALSO
  480.       UseObject()
  481.  
  482.       AddNodeBinTree()
  483.       AddNodeStringBinTree()        AddNodeStringWatchedBinTree()
  484.       FindBinNode()
  485.       FreeAllNodesBinTree()
  486.       RecurseBinTree()
  487.       RemoveBinNode()               RemoveWatchedBinNode()
  488.       RemoveStringBinNode()         RemoveStringWatchedBinNode()
  489.  
  490. NAME
  491.       AddSListNode -- Adds a node to a prioritized singly linked list.
  492.  
  493. SYNOPSIS
  494.       result = AddSListNode( list, object, pri, name )
  495.         d0                    a0     a1     d0   d1
  496.  
  497. FUNCTION
  498.       This function adds an object into a singly linked list with the
  499.       given name at the given priority (list is ordered by
  500.       priority).
  501.  
  502.  
  503. INPUTS
  504.       SList               *list; - a pointer to the list to which to add
  505.                                     the object.
  506.       OBJECT             object; - the object to add.
  507.       long                  pri; - the priority
  508.       char                *name; - the name to add it as.
  509.  
  510.  
  511. OUTPUTS
  512.       BOOL result; - result code
  513.  
  514.       The result code is an integer indicating the success or failure of
  515.       the function call.  A zero value indicates that an error occured.
  516.  
  517.       Lists of equal priorities are treated as LIFOs.
  518.  
  519.  
  520. RESULT
  521.       The list has one more node on it -- the passed object.
  522.  
  523. BUGS
  524.       none known.
  525.  
  526. NOTES
  527.  
  528. SEE ALSO
  529.       FindNodePriInSList()                AddWatchedSListNode()
  530.       RemoveSListNode()                   RemoveWatchedSListNode()
  531.  
  532. NAME
  533.       AddWatchedSListNode -- Adds a node to a watched, prioritized singly-
  534.                               linked list.
  535.  
  536. SYNOPSIS
  537.       result = AddWatchedSListNode( list, object, pri, name )
  538.         d0                           a0     a1     d0   d1
  539.  
  540. FUNCTION
  541.       This function adds an object into a watched, singly-linked list with
  542.       the given name at the given priority (list is ordered by priority).
  543.  
  544.       If any parties are interested, WatcherDispatch is called with
  545.       W_INSERT_NODE for the flag paramter.
  546.  
  547.  
  548. INPUTS
  549.       W_SLIST              list; - a pointer to the list to which to add
  550.                                     the object.
  551.       OBJECT             object; - the object to add.
  552.       long                  pri; - the priority
  553.       char                *name; - the name to add it as.
  554.  
  555.  
  556. OUTPUTS
  557.       BOOL result; - result code
  558.  
  559.       The result code is an integer indicating the success or failure of
  560.       the function call.  A zero value indicates that an error occured.
  561.  
  562.  
  563. RESULT
  564.       The list has one more node on it -- the passed object.
  565.  
  566. BUGS
  567.       none known.
  568.  
  569. NOTES
  570.  
  571. SEE ALSO
  572.       AddSListNode()
  573.       FindNodePriInSList()
  574.       RemoveSListNode()                   RemoveWatchedSListNode()
  575.  
  576. NAME
  577.       AddWatcherNode -- Adds a watcher to the watched variable
  578.  
  579. SYNOPSIS
  580.       result = AddWatcherNode( wv, node, pri, name )
  581.         d0                     a0   a1    d0   d1
  582.  
  583. FUNCTION
  584.       This function will add a watcher object (sometimes referred to
  585.       as a 'director') into the WatchedVariable wv.
  586.  
  587.       This is a low-level routine.  You should use the provided
  588.       DIRECTORCLASS method.  See browser.c for some examples, or the
  589.       included ShadowLibMethods.doc for more details.
  590.  
  591.  
  592. INPUTS
  593.       W_VALUE              wv; - the watched variable to watch
  594.       OBJECT             node; - the director to add to the watch list.
  595.       long                pri; - the priority to add the watcher as.
  596.       char              *name; - the name of the watcher.
  597.  
  598. OUTPUTS
  599.       BOOL              result; - result code
  600.  
  601.       The result code is a boolean indicating the success or failure of
  602.       the function call.  A zero value indicates that an error occured.
  603.  
  604.  
  605. RESULT
  606.       The director is added to the watch list.
  607.  
  608. BUGS
  609.       none known.
  610.  
  611. NOTES
  612.  
  613. SEE ALSO
  614.       RemoveWatcherNode()
  615.       AddClassWatcher()
  616.       RemoveClassWatcher()
  617.  
  618. NAME
  619.       AllocateItem -- Allocates an item from a MemoryList
  620.  
  621. SYNOPSIS
  622.       element = AllocateItem( list )
  623.          d0                    a0
  624.  
  625. FUNCTION
  626.       Allocates an element from the list.
  627.       The element will NOT be zeroed out, and may contain data from the
  628.       last time that element was used.
  629.  
  630.       Elements are allocated 32 at a time via the allocfunc() that was
  631.       passed to the InitTable() function.  AllocateItem() doles out
  632.       these elements one by one, automatically calling allocfunc()
  633.       when necessary.
  634.  
  635.  
  636. INPUTS
  637.       SEMLIST list; - the list to allocate from.
  638.  
  639. OUTPUTS
  640.       void *element; - element that is allocated.
  641.  
  642.       As with any allocation function, this function can return NULL for
  643.       a failure to allocate memory.
  644.  
  645.  
  646. RESULT
  647.       One item is allocated on the Memorylist
  648.  
  649. BUGS
  650.       none known.
  651.  
  652. NOTES
  653.  
  654. SEE ALSO
  655.       InitTable()
  656.       FreeTable()
  657.       FreeItem()
  658.  
  659. NAME
  660.       BindSuperWatchers -- copies all watchers on the superClass' watched
  661.                             attributes to the subclass.
  662.  
  663. SYNOPSIS
  664.       result = BindSuperWatchers( class )
  665.         d0                          a0
  666.  
  667. FUNCTION
  668.       This function is called internally during METHOD_META_INIT of all
  669.       classes and metas.
  670.       A search is done on the immediate superClass' attributes.  Any
  671.       watchers found on the class' attribute list are copied to the
  672.       passed class' attribute.
  673.  
  674.       Thus, if a new class subclassed off of WindowClass was created
  675.       while running browser, the watcher that was watching all of the
  676.       window classes will watch that new window class as well.
  677.  
  678.  
  679. INPUTS
  680.       META class; - the (sub)class to bind the watchers.
  681.  
  682. OUTPUTS
  683.       BOOL result; - the result code.
  684.  
  685.       FALSE indicates failure to copy all the watchers.  Probably ran out
  686.       of memory allocating list nodes.
  687.  
  688. RESULT
  689.       The class' watched variables can now send out notification to the
  690.       old class watchers for any new objects that are created and stored
  691.       there, or for any changes in value made to the watched variable.
  692.  
  693. BUGS
  694.       none known.
  695.  
  696. NOTES
  697.  
  698. SEE ALSO
  699.       BindWatchers()
  700.       AddWatcherNode()
  701.       AddClassWatcher()
  702.       WatcherDispatch()
  703.  
  704. NAME
  705.       BindWatchers -- binds all object's attributes' watched wv_firstClass
  706.                        to the appropriate spot in the object's class.
  707.  
  708. SYNOPSIS
  709.       BindWatchers( object )
  710.                        a0
  711.  
  712. FUNCTION
  713.       This function is called internally during METHOD_META_INIT of all
  714.       objects.  It sets all watched variables in the object to have their
  715.       wv_firstClass pointer pointing to the class' attributes' SList,
  716.       like it is supposed to.
  717.  
  718.       This allows notification of any changes to the watched variable to
  719.       be sent out on a class basis -- any object of the class will
  720.       attempt to send notification to both the specific object, and
  721.       the associated class.
  722.  
  723.       An example is in browser.c which is notified whenever any object
  724.       is added to the ATTR_GUICHILDREN of any object whose class is
  725.       a descendent of WindowClass.
  726.  
  727.  
  728. INPUTS
  729.       OBJECT object; - the object to bind the watchers.
  730.  
  731. OUTPUTS
  732.  
  733.  
  734. RESULT
  735.       The object's watched variables can now send out notification to the
  736.       class watchers.
  737.  
  738. BUGS
  739.       none known.
  740.  
  741. NOTES
  742.  
  743. SEE ALSO
  744.       BindSuperWatchers()
  745.       AddWatcherNode()
  746.       AddClassWatcher()
  747.       WatcherDispatch()
  748.  
  749. NAME
  750.       BlockMethod -- [un]blocks via a METHOD_FLAG_PREBLOCK, the method
  751.                      in a given class.
  752.  
  753. SYNOPSIS
  754.       BlockMethod( class, name, pri, block )
  755.                     a0     a1    d0    d1
  756.  
  757. FUNCTION
  758.       This function will search the class for a method of the given name.
  759.       If pri is non-zero, the patched verbs list of the class is searched
  760.       for a method patch of the given name and priority.
  761.  
  762.       This handle is then either PRE_BLOCK'd or un-PRE_BLOCK'd,
  763.       according to the block flag.
  764.  
  765.  
  766. INPUTS
  767.       META         class; - the class where the method is found.
  768.       char         *name; - the name of the method to [un]block.
  769.       WORD           pri; - the priority (or nearest priority) of where
  770.                                  the block should take effect.
  771.                             If pri is non-zero, a patch of that pri must
  772.                                  exist.
  773.       WORD         block; - whether to block (TRUE) or to unblock (FALSE)
  774.  
  775. OUTPUTS
  776.       none
  777.  
  778.  
  779. RESULT
  780.       A method may be [un]blocked.
  781.  
  782. BUGS
  783.       none known.  Not yet tested!  (31 Jan 1992)
  784.  
  785. NOTES
  786.  
  787. SEE ALSO
  788.       DJM()                            DoJazzMethod()
  789.       InvalidateCache()
  790.       SetMethodArgs()
  791.       AddMethods()
  792.       DestroyMethodTable()
  793.       FindMethodHandle()
  794.       RemoveAllPatches()
  795.       SetupMethodTags()
  796.  
  797. NAME
  798.       ChangeWatchedValue -- Changes a watched variable's value.
  799.  
  800. SYNOPSIS
  801.       ChangeWatchedValue( wv, new )
  802.                           a0   d0
  803.  
  804. FUNCTION
  805.  
  806.       Changes the watched variable to the passed new value.
  807.  
  808.       If any parties are interested, WatcherDispatch is called with
  809.       either W_CHANGE_ZERO or W_CHANGE_NON_ZEROin the flag parameter.
  810.  
  811.  
  812. INPUTS
  813.       W_VALUE              wv; - a watched variable to change.
  814.       long                new; - the value to change to.
  815.  
  816. OUTPUTS
  817.  
  818.  
  819. RESULT
  820.       The value is changed, and all parties notified.
  821.  
  822. BUGS
  823.       none known.
  824.  
  825. NOTES
  826.  
  827. SEE ALSO
  828.       WatcherDispatch()
  829.  
  830. NAME
  831.       CopyDefaultAttributes -- Copy the default attrs into the instance
  832.  
  833. SYNOPSIS
  834.       CopyDefaultAttributes( object )
  835.                                a0
  836.  
  837. FUNCTION
  838.       This function will copy the default values, specified in the
  839.       object's class, into the object.  It is executed by both MetaClass
  840.       and MetaCluster, and by both rootClass and rootCluster in the
  841.       METHOD_META_CREATE method.
  842.  
  843.       It assumes the object is already filled with ZEROs.
  844.  
  845.  
  846. INPUTS
  847.       OBJECT object; - The object whose attributes should be initialized.
  848.  
  849. OUTPUTS
  850.       none
  851.  
  852.  
  853. RESULT
  854.       The object's attributes are initialized to the attribute default
  855.       values stored in the object's class.
  856.       Object is assumed to have already been initialized to ZEROs.
  857.  
  858. BUGS
  859.       none known.
  860.  
  861. NOTES
  862.       object is a required parameter.
  863.  
  864. SEE ALSO
  865.       PrepareAttrTags()
  866.       AddAttributes()
  867.       FreeAttributes()
  868.       FindAttribute()
  869.       FindAttrDefn()
  870.  
  871. NAME
  872.       CreateMeta -- Creates a self-referencing class description.
  873.  
  874. SYNOPSIS
  875.       meta = CreateMeta( description )
  876.        d0                    a0
  877.  
  878. FUNCTION
  879.       This function creates a Meta.
  880.  
  881.       A Meta is a class whose class is itself.  It is useful for
  882.       describing Classes and such.  The current system creates two
  883.       Metas:  MetaClass and MetaCluster.
  884.  
  885.       The description is used to create the Meta using the attributes
  886.       and superClass pointers.  The superClass field, the attribute
  887.       table and the method table are all filled in.  The name is NOT,
  888.       nor is any other information in the description touched.
  889.  
  890.       The description's object and class pointers are set up as 'meta',
  891.       the method is initialized either to METHOD_META_INIT (if passed
  892.       as NULL) or left as passed (if not NULL).
  893.  
  894.       CreateMeta then returns "DJM(description, SHADOW_MSG_FINDMETHOD)".
  895.  
  896.       This implies several things:
  897.  
  898.          You can create meta structures that need initialization by
  899.          passing the appropriate arguments in the InitMeta structure.
  900.          See the InitMeta structure for more details.
  901.  
  902.          Your METHOD_META_INIT methods should now -do-the-right-thing-
  903.          when passed its own meta, rather than a proper instance of
  904.          that meta.  The correct method for checking for such an event
  905.          is to compare 'object' with 'object->cob_class' as in:
  906.  
  907.             MyMethod(METHOD_ARGS, MYMETHODARGS)
  908.             {
  909.                if (object == object->cob_class)
  910.                {
  911.                   /*
  912.                    * we were passed a meta, so
  913.                    *  do what we needed to do with that.
  914.                    */
  915.                } else
  916.                {
  917.                   /*
  918.                    * We were passed a proper instance, so do
  919.                    *  what is necessary here.
  920.                    */
  921.                }
  922.             }
  923.          Specifically, you should NOT do a comparison between 'object'
  924.          and 'class'.  Class can change if called as a superclass method.
  925.          The object might still be a meta, just not THAT method's meta....
  926.  
  927.          As always, the following methods should also handle being sent a
  928.          Meta:  METHOD_META_DESTROY, METHOD_META_REMOVE.
  929.  
  930.          METHOD_META_SUB should also handle Metas by filling in the
  931.          superClass pointer and passing the arguments to CreateMeta.
  932.          The following code segment may be useful:
  933.  
  934.             MethodMetaSub(METHOD_ARGS, name, superClass, attrList, verbList)
  935.             {
  936.                if (!superClass)
  937.                   superClass = object;
  938.  
  939.                if (object == object->cob_class)
  940.                {
  941.                   struct InitMeta *im;
  942.  
  943.                   im = (struct InitMeta *)&object;
  944.  
  945.                   im->im_object = im->im_class = NULL;
  946.                   im->im_method = NULL;
  947.                   im->im_super = superClass;    /* Sigh... */
  948.                   return CreateMeta(im);
  949.                }
  950.  
  951.                .
  952.                .
  953.                .
  954.             }
  955.  
  956.          A consequence of using METHOD_META_SUB to create new Metas is
  957.          that the initialization parameters are truncated to match the
  958.          METHOD_META_SUB parameter description, which might not pass
  959.          all the required parameters into the InitMeta structure sent
  960.          to CreateMeta!  Please remember what you are doing.
  961.  
  962.       The description structure that is passed is a fixed length header
  963.       with a variable length number of additional arguments (which should
  964.       match the initialization routine CreateMeta calls: either the contents
  965.       of description->im_method OR METHOD_META_INIT if that is NULL).  As
  966.       a result, this argument list MUST be terminated by a METHOD_END.
  967.  
  968.       Your initialization routine is responsible for setting the Meta's name
  969.       and adding the meta to ShadowBase->sb_metaTree.
  970.  
  971.       The instances of Metas have, likewise, the same attributes as the Meta
  972.       (as part of their instance, where the Metas have those attributes in
  973.       both the INSTANCE and in their attribute description table).
  974.  
  975.       Reminder:
  976.          the METHOD_META_REMOVE of the meta must distinguish between
  977.          the case where the passed object != meta (meaning the object
  978.          is an instance of Meta, and so should be removed from the
  979.          ATTR_OBJECTLIST of the object->cob_class) and the case where
  980.          object == meta (meaning the object *is* the meta, and should be
  981.          removed from the system's metaTree -- &ShadowBase->sb_metaTree).
  982.  
  983.          Similarly for METHOD_META_DESTROY -- don't drop the object's
  984.          cob_class when you destroy the meta
  985.          (ie: object == object->cob_class), and do transfer the class
  986.          if (object == class) :: (IpcARGTransfer(msg, 1).
  987.  
  988.  
  989. INPUTS
  990.       struct InitMeta *im; - the initialization description.  See includes
  991.  
  992. OUTPUTS
  993.       META           meta; - the meta that was created.  NULL if error.
  994.  
  995.  
  996. RESULT
  997.  
  998. BUGS
  999.       none known.
  1000.  
  1001. NOTES
  1002.  
  1003. SEE ALSO
  1004.       UseObject()
  1005.       DropObject()
  1006.       FindInstanceInMeta()
  1007.  
  1008. NAME
  1009.       CreateObject -- creates an object with the same data as the ptr.
  1010.  
  1011. SYNOPSIS
  1012.       object = CreateObject( ptr, size )
  1013.         d0                    a0   d0
  1014.  
  1015. FUNCTION
  1016.       This function creates a ClasslessObject, which can be UseObject()'d
  1017.       and DropObject()'d at will, whose included data is the data
  1018.       located in ptr, covering "size" bytes.
  1019.  
  1020.       If given both a non-NULL pointer and non-zero size, it allocates
  1021.       an object of sizeof(struct ClasslessObject)+size and sets up
  1022.       the fields according to what a ClasslessObject should look like:
  1023.  
  1024.             clb_size = size;
  1025.             clb_useCount = 1;
  1026.             clb_class = NULL;
  1027.  
  1028.       As noted, the returned object is Use'd once, so it should be
  1029.       DropObject()'d when its life expires.
  1030.  
  1031.  
  1032. INPUTS
  1033.       void     *ptr; - the object to effect the change upon.
  1034.       ULONG    size; - the size of the data pointed to by ptr.
  1035.  
  1036. OUTPUTS
  1037.       OBJECT object; - the allocated object.  NULL if error.
  1038.  
  1039.  
  1040. RESULT
  1041.       A new ClasslessObject is created.
  1042.  
  1043. BUGS
  1044.       none known.
  1045.  
  1046. NOTES
  1047.  
  1048. SEE ALSO
  1049.       UseObject()
  1050.       DropObject()
  1051.  
  1052. NAME
  1053.       DestroyMethodTable -- frees the array of methods.
  1054.  
  1055. SYNOPSIS
  1056.       DestroyMethodTable( table )
  1057.                             a0
  1058.  
  1059. FUNCTION
  1060.       This function will destroy the MethodTable's array of
  1061.       MethodHandlers (usually the class' meta_verbs field).
  1062.  
  1063.       It resource-tracks the procObject, defnObject, and method names
  1064.       in the MethodHandler elements.
  1065.  
  1066.  
  1067. INPUTS
  1068.       struct MethodTable *table; - required parameter.  Usually found in
  1069.                                     class->meta_verbs.
  1070.  
  1071. OUTPUTS
  1072.  
  1073.  
  1074. RESULT
  1075.       The array, if a non-NULL ptr, is freed.
  1076.  
  1077. BUGS
  1078.       none known.
  1079.  
  1080. NOTES
  1081.  
  1082. SEE ALSO
  1083.       DJM()                            DoJazzMethod()
  1084.       InvalidateCache()
  1085.       SetMethodArgs()
  1086.       AddMethods()
  1087.       FindMethodHandle()
  1088.       BlockMethod()
  1089.       RemoveAllPatches()
  1090.       SetupMethodTags()
  1091.  
  1092. NAME
  1093.       DJM -- parses out the requested method, calls and/or sends out
  1094.              the appropriate function(s)/message(s)
  1095.  
  1096. SYNOPSIS
  1097.       result = DJM( arguments, flags )
  1098.         d0             a1        d1
  1099.  
  1100. FUNCTION
  1101.       This function is the work horse of the entire system.  It is
  1102.       responsible for sending off all METHODs, whether synchronously,
  1103.       asynchronously, or as a function call.  In addition, it also sends
  1104.       off all method patches as requested.
  1105.  
  1106.       DJM() caches methods for faster lookups (a bit more than twice as
  1107.       fast in worst case function calls).
  1108.  
  1109.       DJM() checks the class' doMethod function callback both BEFORE and
  1110.       AFTER any SHADOW_MSG_SUPER handling.  This callback should act like
  1111.       DJM(), if you want to change the way DJM() works.
  1112.  
  1113.       If flags specifies that the methods should be forced to send all
  1114.       methods SHADOW_MSG_ASYNC or SHADOW_MSG_FORCE_ASYNC, then a single
  1115.       message is sent to the primary handle's procObject asynchronously
  1116.       with the function callback set back to DJM.  DJM() is then called,
  1117.       where the message is parsed out by MessageParse() (Usually handled
  1118.       by ParseJazzMessage()), and the methods sent out as usual.  This is
  1119.       to correctly handle the asyn. case of METHOD_FLAG_CHECK_CONTINUE.
  1120.  
  1121.       The following METHOD_FLAGs are passed in at method or patch creation
  1122.       in the MethodTag mtag_flags field:
  1123.  
  1124.       METHOD_FLAG_[POST|PRE]_BLOCK ends the sending of methods off as
  1125.       DJM() works from the highest priority patch, to the normal
  1126.       MethodHandle, to the lowest priority patch.  POST_BLOCK ends the
  1127.       method chain after -that- method in the patch-chain is sent off,
  1128.       PRE_BLOCK ends it BEFORE that method is sent off.
  1129.  
  1130.       METHOD_FLAG_RTRN_ME informs DJM() that a patch wishes to use
  1131.       its return value as a possible return value, if no other method
  1132.       returns something farther down the priority chain.  This is the
  1133.       default for ALL methods creatd by AddMethods().
  1134.  
  1135.       METHOD_FLAG_CHECK_CONTINUE checks the return value returned in
  1136.       d1 (that's d1, not d0).  If d1 is TRUE, then the method-chain
  1137.       is continued, if FALSE (zero), then the method chain ends at
  1138.       that point.
  1139.  
  1140.       A method-chain exists whenever a method is patched.  These patches
  1141.       are called from high priority to zero, when the regular handle is
  1142.       called, and then lower priority patches are called.  This chain
  1143.       of method calls can be terminated by the *_BLOCK or CHECK_CONTINUE
  1144.       flags mentioned above.
  1145.  
  1146.  
  1147. INPUTS
  1148.       void **arguments; - a pointer to the arguments.  First should be the
  1149.                            object, then a valid class, then a method, then
  1150.                            the rest of the arguments according to the
  1151.                            MethodRef structure, ending with a METHOD_END
  1152.                            (0x80000001)
  1153.       ULONG      flags; - if low byte non-zero, treat as a specification
  1154.                            for the type of method to send (SHADOW_MSG_CALL,
  1155.                            etc.).  A SHADOW_MSG_FORCE alone specifies
  1156.                            that the method should be called.  The flag
  1157.                            affects any method patches as well.
  1158.                           SHADOW_MSG_SUPER indicates the method should be
  1159.                            sent to the superclass of the class as poassed
  1160.                            in arguments[1].
  1161.                           SHADOW_MSG_FINDMETHOD indicates that the method
  1162.                            needs to be lookup up in the systemString via
  1163.                            the FindString call.
  1164.  
  1165. OUTPUTS
  1166.       void *result; - result from method parse.
  1167.  
  1168.  
  1169. RESULT
  1170.  
  1171. BUGS
  1172.       none known.
  1173.  
  1174. NOTES
  1175.  
  1176. SEE ALSO
  1177.                                        DoJazzMethod()
  1178.       InvalidateCache()
  1179.       SetMethodArgs()
  1180.       AddMethods()
  1181.       DestroyMethodTable()
  1182.       FindMethodHandle()
  1183.       BlockMethod()
  1184.       RemoveAllPatches()
  1185.       SetupMethodTags()
  1186.  
  1187. NAME
  1188.       DropObject -- resource tracking for shadow objects.
  1189.  
  1190. SYNOPSIS
  1191.       DropObject( object )
  1192.                     a0
  1193.  
  1194. FUNCTION
  1195.       This function decrements the object's cob_useCount.
  1196.  
  1197.       You should Drop() an object when you free a structure that had a
  1198.       pointer-to-object in it.  In addition, certain method calls, like
  1199.       METHOD_META_INIT return an object to you.  When you are done using
  1200.       the pointer, you are expected to drop the pointer.
  1201.  
  1202.       A word about self-referencing.  Self-referncing is an evil problem
  1203.       in useCount systems.  You should DropObject() all self-references
  1204.       during the METHOD_META_REMOVE call of an object.  For instance, if
  1205.       your class maintained a binary tree of gadget objects, and these
  1206.       gadget objects pointed back to the window object, the
  1207.       IDCMP_WINDOWCLOSE should do a METHOD_META_REMOVE on the window,
  1208.       which in turn should METHOD_META_REMOVE it's gadgets, and those
  1209.       gadgets should remove all references to the window object during
  1210.       that METHOD_META_REMOVE call.
  1211.  
  1212.       If the useCount of the object drops to zero furing DropObject(),
  1213.       the object's destructor (METHOD_META_DESTROY) is called.  If the
  1214.       object in question has no class, than it is assumed to be a
  1215.       ClasslessObject, and the clb_size is looked at.  If this field
  1216.       is non-zero, the object is freed, with
  1217.                      "FreeMem(object, object->clb_size);"
  1218.  
  1219.       You must be careful when designing ASYNC METHOD_META_DESTROY
  1220.       methods -- please see IpcItemTransfer() for further details.
  1221.  
  1222.  
  1223. INPUTS
  1224.       OBJECT             object; - the object to effect the change upon.
  1225.  
  1226. OUTPUTS
  1227.  
  1228.  
  1229. RESULT
  1230.  
  1231. BUGS
  1232.       none known.
  1233.  
  1234. NOTES
  1235.  
  1236. SEE ALSO
  1237.       UseObject()
  1238.       IpcItemTransfer()
  1239.  
  1240. NAME
  1241.       DropString -- Removes a reference to a system string.
  1242.  
  1243. SYNOPSIS
  1244.       DropString( buffer )
  1245.                     a2
  1246.  
  1247. FUNCTION
  1248.       This function searches the system string list for the system
  1249.       string corresponding to the passed buffer, then decrements
  1250.       the internal usage counter for that system string by one.
  1251.  
  1252.       If the counter becomes zero, that system string is freed from
  1253.       memory.
  1254.  
  1255.       If no string can be found to match buffer, no action is taken.
  1256.  
  1257.  
  1258. INPUTS
  1259.       char *buffer; - equivalent string to the system string that you
  1260.                       want the system to drop a reference to.
  1261.  
  1262. OUTPUTS
  1263.  
  1264.  
  1265. RESULT
  1266.       The system string corresponding to the passed buffer has one
  1267.       fewer references to it.
  1268.  
  1269. BUGS
  1270.       none known.
  1271.  
  1272. NOTES
  1273.       The buffer should be word-aligned for fastest access.
  1274.  
  1275. SEE ALSO
  1276.       UseString()
  1277.       QuickUseString()
  1278.       FindString()
  1279.       QuickDropString()
  1280.  
  1281. NAME
  1282.       FindAttrDefn -- Finds the attribute structure in the class
  1283.  
  1284. SYNOPSIS
  1285.       attribute = FindAttrDefn( class, name )
  1286.          d0                       a0    a1
  1287.  
  1288. FUNCTION
  1289.       This function finds the Attribute structure (the element in the
  1290.       class' array) of the specified class.
  1291.  
  1292.       If the class has a callback attribute function, that function is
  1293.       called instead.
  1294.  
  1295.       Otherwise, the array is radix searched for the attribute whose
  1296.       name corresponds to FindString(name).
  1297.  
  1298.  
  1299. INPUTS
  1300.       META         class; - the class whose attribute is wanted
  1301.                              returns NULL for a NULL class.
  1302.       char         *name; - the name of the attribute to find.
  1303.  
  1304. OUTPUTS
  1305.       struct Attribute *attribute; - pointer to the Attribute structure as
  1306.                                       specified in the class.
  1307.  
  1308.  
  1309. RESULT
  1310.  
  1311. BUGS
  1312.       none known.
  1313.  
  1314. NOTES
  1315.  
  1316. SEE ALSO
  1317.       PrepareAttrTags()                   FindString()
  1318.       AddAttributes()
  1319.       CopyDefaultAttributes()
  1320.       FreeAttributes()
  1321.       FindAttribute()
  1322.  
  1323. NAME
  1324.       FindAttribute -- Finds the instance of the attribute in the object
  1325.  
  1326. SYNOPSIS
  1327.       attribute = FindAttribute( object, name )
  1328.          d0                        a0     a1
  1329.  
  1330. FUNCTION
  1331.       This function will find the specified structure inside of the object
  1332.       and return the address of that structure.
  1333.  
  1334.       Calls FindAttrDefn() on the object's class.
  1335.  
  1336.  
  1337. INPUTS
  1338.       OBJECT             object; - the object whose attribute is wanted.
  1339.                                     returns NULL for a NULL object, or
  1340.                                     an object with a NULL class.
  1341.       char                *name; - the name of the attribute to find.
  1342.  
  1343. OUTPUTS
  1344.       void *attribute; - pointer to the object's attribute.  This
  1345.                           pointer points to the insides of an object.
  1346.  
  1347.  
  1348. RESULT
  1349.  
  1350. BUGS
  1351.       none known.
  1352.  
  1353. NOTES
  1354.       Calls FindAttrDefn internally.
  1355.  
  1356. SEE ALSO
  1357.       PrepareAttrTags()
  1358.       AddAttributes()
  1359.       CopyDefaultAttributes()
  1360.       FreeAttributes()
  1361.       FindAttrDefn()
  1362.  
  1363. NAME
  1364.       FindBinNode -- Finds the object in the binary tree
  1365.  
  1366. SYNOPSIS
  1367.       object = FindBinNode( bt, key )
  1368.         d0                  a0  d0
  1369.  
  1370. FUNCTION
  1371.       This function returns the first object in the binary tree that matched
  1372.       the key passed to the function.
  1373.  
  1374.       Note that a corollary function FindStringInBinTree() is usually defined
  1375.       as FindBinNode(bt, FindString(name)).
  1376.  
  1377.       The object is Used() via the UseObject() call.  When the pointer that
  1378.       is returned is no longer needed, it should be Dropped() via the
  1379.       DropObject() call.
  1380.  
  1381.  
  1382. INPUTS
  1383.       AVLTREE   *bt; - a pointer to the root of the binary tree.
  1384.       ULONG     key; - the key to look for.
  1385.  
  1386. OUTPUTS
  1387.       OBJECT object; - the object that is found
  1388.  
  1389.       NULL is returned if no object is found.
  1390.  
  1391. RESULT
  1392.       The node is located in the binary tree.
  1393.  
  1394. BUGS
  1395.       none known.
  1396.  
  1397. NOTES
  1398.       Please DropObject() any objects returned when no longer needed.
  1399.       Remember that the keys are sorted unsigned, not signed.
  1400.  
  1401. SEE ALSO
  1402.       UseObject()/DropObject()
  1403.  
  1404.       AddNodeBinTree()           AddNodeWatchedBinTree()
  1405.       AddNodeStringBinTree()     AddNodeStringWatchedBinTree()
  1406.       FreeAllNodesBinTree()      RemoveWatchedBinNode()
  1407.       RecurseBinTree()           RemoveStringWatchedBinNode()
  1408.       RemoveBinNode()
  1409.       RemoveStringBinNode()
  1410.  
  1411. NAME
  1412.       FindInstanceInMeta -- Bi-level search for instances of a Meta
  1413.  
  1414. SYNOPSIS
  1415.       class = FindInstanceInMeta( className, metaName )
  1416.         d0                            a0        a1
  1417.  
  1418. FUNCTION
  1419.       This function is useful for finding a Class.  A Class always resides
  1420.       in the ATTR_OBJECTLIST of its defining Meta (until removed via the
  1421.       METHOD_META_REMOVE method).  The Metas all reside in
  1422.       ShadowBase->sb_metaTree.  Therefore, it takes two
  1423.       FIndStringInWatchedBinTree() calls to find a class (or Cluster).
  1424.  
  1425.       This is how FindJazzClass() and FindJazzCluster() are #defined....
  1426.  
  1427.  
  1428. INPUTS
  1429.       char *className; - the name of the class you are looking for.
  1430.       char  *metaName; - the name of the Meta that the class is in.
  1431.  
  1432. OUTPUTS
  1433.       OBJECT    class; - the pointer to the class.  NULL if can't find.
  1434.  
  1435. RESULT
  1436.  
  1437. BUGS
  1438.       none known.
  1439.  
  1440. NOTES
  1441.       You should DropObject() the class when you are finished using it.
  1442.  
  1443.  
  1444. SEE ALSO
  1445.       UseObject()
  1446.       DropObject()
  1447.       CreateMeta()
  1448.  
  1449. NAME
  1450.       FindMethodHandle -- finds the associated handle in the class.
  1451.  
  1452. SYNOPSIS
  1453.       handle = FindMethodHandle( class, method )
  1454.         d0                         a0     a1
  1455.  
  1456. FUNCTION
  1457.       This function will search the class' verb table for the
  1458.       required method.  It does not look in any superclasses to
  1459.       find it.
  1460.  
  1461.  
  1462. INPUTS
  1463.       META      class; - the (optinal) class in which to find the method.
  1464.       char    *method; - the name of the method to look for.
  1465.  
  1466. OUTPUTS
  1467.       struct MethodHandle *handle; - the returned handle.  NULL if not
  1468.                                       found.
  1469.  
  1470.  
  1471. RESULT
  1472.  
  1473. BUGS
  1474.       none known.
  1475.  
  1476. NOTES
  1477.  
  1478. SEE ALSO
  1479.       DJM()                            DoJazzMethod()
  1480.       InvalidateCache()
  1481.       SetMethodArgs()
  1482.       AddMethods()
  1483.       DestroyMethodTable()
  1484.       BlockMethod()
  1485.       RemoveAllPatches()
  1486.       SetupMethodTags()
  1487.  
  1488. NAME
  1489.       FindNodePriInSList -- Finds an object in the singly linked list
  1490.  
  1491. SYNOPSIS
  1492.       object = FindNodePriInSList( list, pri, name )
  1493.         d0                          a0    d0   a1
  1494.  
  1495. FUNCTION
  1496.       This function finds an object in a singly linked list with the
  1497.       given name at the given priority (list is ordered by
  1498.       priority).
  1499.  
  1500.  
  1501. INPUTS
  1502.       SList               *list; - a pointer to the list in which to find
  1503.                                     the object.
  1504.       long                  pri; - the priority
  1505.       char                *name; - the name it was added as.
  1506.  
  1507.  
  1508. OUTPUTS
  1509.       OBJECT             object; - the object, if found.  NULL otherwise.
  1510.  
  1511.  
  1512. RESULT
  1513.  
  1514. BUGS
  1515.       none known.
  1516.  
  1517. NOTES
  1518.       The found object is UseObject()'d, please DropObject() it when you
  1519.       are finished using the pointer.
  1520.  
  1521. SEE ALSO
  1522.       AddSListNode()                      AddWatchedSListNode()
  1523.       RemoveSListNode()                   RemoveWatchedSListNode()
  1524.  
  1525.       UseObject()
  1526.       DropObject()
  1527.  
  1528. NAME
  1529.       FindString -- Find a system string
  1530.  
  1531. SYNOPSIS
  1532.       string = FindString( buffer )
  1533.         d0                   a2
  1534.  
  1535. FUNCTION
  1536.       This function hashes the buffer string and searches on the
  1537.       collision binary tree for any matches.
  1538.  
  1539.       It will return the system string, if it finds it.  It will NOT
  1540.       incremeent the internal useCount, so you should not use what is
  1541.       returned as either a system string, nor even as a string, but
  1542.       merely as an address you are searching a table for -- and
  1543.       even then, you must be careful of race conditions, the address
  1544.       should remain valid for the entire time you are searching a
  1545.       table or structure, or the table/structure must be locked in
  1546.       memory during the time you are searching it.
  1547.  
  1548.  
  1549. INPUTS
  1550.       char *buffer; - the buffer whose system string you want to find.
  1551.                                                 Given a NULL, will
  1552.                                                 return a NULL
  1553.  
  1554. OUTPUTS
  1555.       char *string; - the string, if found.  NULL if no string.
  1556.  
  1557.  
  1558. RESULT
  1559.  
  1560. BUGS
  1561.       none known.
  1562.  
  1563. NOTES
  1564.       The buffer should be word-aligned for fastest access.
  1565.  
  1566. SEE ALSO
  1567.       UseString()
  1568.       QuickUseString()
  1569.       DropString()
  1570.       QuickDropString();
  1571.  
  1572. NAME
  1573.       FreeAllNodesBinTree -- Frees all nodes in a particular binary tree
  1574.  
  1575. SYNOPSIS
  1576.       FreeAllNodesBinTree( bt )
  1577.                            a0
  1578.  
  1579. FUNCTION
  1580.       This function will remove all nodes off of the binary tree, dropping
  1581.       all objects, and all strings.
  1582.  
  1583.       The binary tree is assumed to contain objects sorted on a string as
  1584.       a key.  Please do not call it on any other type of binary tree, as
  1585.       it would be dropping potnetially non-existant string objects.
  1586.  
  1587.       V4.2 UPDATE!  You may now call it with a binary tree that is sorted
  1588.       on keys identical to the pointer to the objects each node holds.
  1589.          ie: keys added with:
  1590.                AddNodeBinTree(&bt, object, object);
  1591.       -or- with keys of less than 256, which are assumed to be merely
  1592.       longwords....
  1593.  
  1594.  
  1595. INPUTS
  1596.       AVLTREE *bt; - a pointer to the root of the binary tree.
  1597.  
  1598. OUTPUTS
  1599.  
  1600.  
  1601. RESULT
  1602.       bt is now a pointer to an empty binary tree.
  1603.  
  1604. BUGS
  1605.       none known.
  1606.  
  1607. NOTES
  1608.       Don't call this function on a binary tree sorted by keys that aren't
  1609.       system strings, aren't less than 256 or aren't equal to the
  1610.       corresponding object.
  1611.  
  1612. SEE ALSO
  1613.       AddNodeBinTree()           AddNodeWatchedBinTree()
  1614.       AddNodeStringBinTree()     AddNodeStringWatchedBinTree()
  1615.       FindBinNode()              RemoveWatchedBinNode()
  1616.       RecurseBinTree()           RemoveStringWatchedBinNode()
  1617.       RemoveBinNode()
  1618.       RemoveStringBinNode()
  1619.  
  1620. NAME
  1621.       FreeAttributes -- Frees all Attribute structures for the class
  1622.  
  1623. SYNOPSIS
  1624.       FreeAttributes( table )
  1625.                         a0
  1626.  
  1627. FUNCTION
  1628.       This function will free the array of Attributes in the
  1629.       AttributeTable.  Called during METHOD_META_DESTROY for classes
  1630.       and metas.
  1631.  
  1632.  
  1633. INPUTS
  1634.       struct AttributeTable *table; - pointer to the attribute table to
  1635.                                        free.  Probably a pointer into a
  1636.                                        class that is going away.
  1637.  
  1638. OUTPUTS
  1639.       none
  1640.  
  1641.  
  1642. RESULT
  1643.       The memory allocated in that table is freed.  The Table structure
  1644.       itself is NOT freed.
  1645.  
  1646. BUGS
  1647.       Should probably be called DestroyAttributeTable()
  1648.  
  1649. NOTES
  1650.       table is a required parameter
  1651.  
  1652. SEE ALSO
  1653.       PrepareAttrTags()
  1654.       AddAttributes()
  1655.       CopyDefaultAttributes()
  1656.       FindAttribute()
  1657.       FindAttrDefn()
  1658.  
  1659. NAME
  1660.       FreeClassWatchers -- frees all the watchers in the class' attributes
  1661.  
  1662. SYNOPSIS
  1663.       FreeClassWatchers( class )
  1664.                            a0
  1665.  
  1666. FUNCTION
  1667.       This function frees all watchers left on any of the class'
  1668.       attribute-watching SLists.
  1669.  
  1670.  
  1671. INPUTS
  1672.       META class; - the class whose attributes' watchers need to be
  1673.                      removed.
  1674.  
  1675. OUTPUTS
  1676.  
  1677.  
  1678. RESULT
  1679.       All watchers in a class are removed.
  1680.  
  1681. BUGS
  1682.       none known.
  1683.  
  1684. NOTES
  1685.       For some reason, class watchers need to be removed from the class
  1686.       when the class is removed.
  1687.  
  1688.       Therefore, METHOD_META_REMOVE for the metas and roots call this
  1689.       function.
  1690.  
  1691. SEE ALSO
  1692.       FreeObjectWatchers()
  1693.       AddClassWatcher()
  1694.  
  1695. NAME
  1696.       FreeItem -- Frees an element belonging to a MemoryList
  1697.  
  1698. SYNOPSIS
  1699.       FreeItem( list, ptr )
  1700.                  a0   a1
  1701.  
  1702. FUNCTION
  1703.       This function frees an element that was allocated via the
  1704.       AllocateItem() function.  The element may, or may not, be returned
  1705.       to Exec's free memory pool, but may, thereafter, be re-used by
  1706.       AllocateItem for some other program.
  1707.  
  1708.  
  1709. INPUTS
  1710.       SEMLIST list; - the MemoryList the element belongs to.
  1711.       void    *ptr; - the element pointer
  1712.  
  1713. OUTPUTS
  1714.  
  1715.  
  1716. RESULT
  1717.       The element is returned to be re-used by AllocateItem for the
  1718.       specified MemoryList.
  1719.  
  1720.  
  1721. BUGS
  1722.       Infinite loop occurs if ptr was not on the MemoryList.
  1723.  
  1724. NOTES
  1725.       The MemoryList passed MUST be the MemoryList from which the element
  1726.       was allocated.
  1727.  
  1728. SEE ALSO
  1729.       InitTable()
  1730.       AllocateItem()
  1731.       FreeTable()
  1732.  
  1733. NAME
  1734.       FreeObjectWatchers -- frees all the watchers in the object's vars.
  1735.  
  1736. SYNOPSIS
  1737.       FreeObjectWatchers( object )
  1738.                             a0
  1739.  
  1740. FUNCTION
  1741.       This function removes all watchers from all variables in the object.
  1742.  
  1743.  
  1744. INPUTS
  1745.       OBJECT object; - the object whose watched variables need to be
  1746.                         removed.
  1747.  
  1748. OUTPUTS
  1749.  
  1750.  
  1751. RESULT
  1752.       All watchers of all watched variables in the object are removed.
  1753.  
  1754. BUGS
  1755.       none known.
  1756.  
  1757. NOTES
  1758.       This function, as opposed to FreeClassWatchers(), can be called in
  1759.       the METHOD_META_DESTROY.  The Metas and Roots currently call this
  1760.       function.
  1761.  
  1762. SEE ALSO
  1763.       FreeClassWatchers()
  1764.       AddClassWatcher()
  1765.  
  1766. NAME
  1767.       FreeTable -- free all the memory nodes on the MemoryList
  1768.  
  1769. SYNOPSIS
  1770.       FreeTable( list )
  1771.                   a0
  1772.  
  1773. FUNCTION
  1774.       This function frees all resources that the MemoryList acquired
  1775.       during run-time.  This means that any outstanding MemoryNodes are
  1776.       thereafter freed -- and therefore not usable to whomever may own
  1777.       them.  No attempt is made to ensure all items have been released
  1778.       before all outstanding MemoryNodes are freed by the freefunc()
  1779.       originally passed to InitTable.
  1780.  
  1781.       FreeItem automatically frees MemoryNodes when it "feels" there are
  1782.       plenty of free elements available for use.  However, that means
  1783.       that even when all elements are FreeItem()'d, there will still be
  1784.       many MemoryNodes on the MemoryList.  This function will free those
  1785.       remaining MemoryNodes.
  1786.  
  1787.  
  1788. INPUTS
  1789.       SEMLIST *list; - the MemoryList to purge.
  1790.  
  1791. OUTPUTS
  1792.  
  1793.  
  1794. RESULT
  1795.       The MemoryList no longer contains any outstanding resources.
  1796.  
  1797. BUGS
  1798.       none known.
  1799.  
  1800. NOTES
  1801.  
  1802. SEE ALSO
  1803.       InitTable()
  1804.       AllocateItem()
  1805.       FreeItem()
  1806.  
  1807. NAME
  1808.       GetTagsSize -- gets the size of a NULL terminated aray.
  1809.  
  1810. SYNOPSIS
  1811.       size = GetTagsSize( tags, size )
  1812.        d0                  a0    d0
  1813.  
  1814. FUNCTION
  1815.       This function will find the size of a longword-NULL-terminated
  1816.       array. The NULL termination should be valid for the first longword
  1817.       of the last array element.
  1818.  
  1819.       The passed size should be the size of each array element.
  1820.  
  1821.  
  1822. INPUTS
  1823.       void *tags; - a pointer to the array.  If NULL, returns NULL
  1824.       long  size; - the size of each element in the array.
  1825.  
  1826. OUTPUTS
  1827.       long  size; - the size of the array, including the NULL element.
  1828.  
  1829.  
  1830. RESULT
  1831.  
  1832. BUGS
  1833.       none known.
  1834.  
  1835. NOTES
  1836.  
  1837. SEE ALSO
  1838.  
  1839. NAME
  1840.       InitOOProgram -- initialize an AmigaDOS process as a shadow process
  1841.  
  1842. SYNOPSIS
  1843.       result = InitOOProgram( name )
  1844.         d0                     a0
  1845.  
  1846. FUNCTION
  1847.       This function will initialize the calling amigaDos process as
  1848.       a SHADOW process.  This means that tc_UserData is HANDS OFF from
  1849.       that point on ('cept for read only).  The process object is stored
  1850.       in tc_UserData and all message ports, etc. are allocated.
  1851.  
  1852.       This function MUST be called before initiating any non-CALL methods.
  1853.       Any methods that would require a SYNC or an ASYNC message
  1854.       require that a process object exist in tc_UserData of the calling
  1855.       task.
  1856.  
  1857.       If you want to use something other than PROCESSCLASS, then you may
  1858.       first set FindTask(NULL)->tc_UserData to NULL, then call
  1859.       METHOD_META_SUB on the process class, then send that class a
  1860.       METHOD_META_CREATE, then send the object that that returns a
  1861.       METHOD_PROC_ASSOCIATE.  That's all this function does....  [Excepting
  1862.       the METHOD_META_SUB call, of course....]
  1863.  
  1864.  
  1865. INPUTS
  1866.       char *name; - the name to give the process object.
  1867.  
  1868.       The name defaults to FindTask(NULL)->tc_Node.ln_Name when passed in
  1869.       as NULL.
  1870.  
  1871. OUTPUTS
  1872.       BOOL result; - result code
  1873.  
  1874.       The result code is a boolean describing success or failure of process
  1875.       object creation.
  1876.  
  1877.       FALSE (0) is an error.
  1878.  
  1879.  
  1880. RESULT
  1881.       Process object is created for the calling task.
  1882.  
  1883. BUGS
  1884.       none known.
  1885.  
  1886. NOTES
  1887.       tc_UserData is trashed (used)
  1888.  
  1889.       You should define a unique class for your program, and try to find
  1890.       that program's class when starting up.  If found, instantiate that
  1891.       already existing class, and exit.
  1892.  
  1893.       See example: browser.c
  1894.  
  1895. SEE ALSO
  1896.       RemoveCurrentProgram()
  1897.  
  1898. NAME
  1899.       InitOOSystem -- private initialization routine by ramlib
  1900.  
  1901. SYNOPSIS
  1902.       result = InitOOSystem( seglist )
  1903.         d0                      a0
  1904.  
  1905. FUNCTION
  1906.       This funtion should ONLY be called by ramlib when the library is
  1907.       starting up.  For some reason the author is documenting the function
  1908.       publically.  Heaven help us.
  1909.  
  1910.       The function's partner is the expunge routine.
  1911.  
  1912.  
  1913. INPUTS
  1914.       seglist     - the library's segment list that was loaded.
  1915.  
  1916. OUTPUTS
  1917.       struct ShadowBase result; - The library base.
  1918.  
  1919.  
  1920. RESULT
  1921.       The library is opened.  MetaClass, metaCluster, rootClass,
  1922.       rootCluster, processClass, directorClass, and patcherClass are all
  1923.       created.
  1924.  
  1925. BUGS
  1926.       none known.
  1927.  
  1928. NOTES
  1929.  
  1930. SEE ALSO
  1931.       DestroyOOSystem (internal name).  AKA Expunge. (ain't no Docs :))
  1932.  
  1933. NAME
  1934.       InitTable -- Initializes a memory table.
  1935.  
  1936. SYNOPSIS
  1937.       result = InitTable( list, allocfunc, freefunc, size )
  1938.         d0                 a0      a1         d0      d1
  1939.  
  1940. FUNCTION
  1941.  
  1942.       Shadow requires a number of very small elements to be coninually
  1943.       allocated and freed.  This function initializes a struct MemoryList
  1944.       which attempts to ease the strain on AllocMem and FreeMem by
  1945.       allocating and freeing blocks that are 32 times "size".
  1946.  
  1947.       The individual elements are allocated via the AllocateItem() and
  1948.       FreeItem() functions.
  1949.  
  1950.       InitTable initializes the various elements of the passed MemoryList
  1951.       structure.
  1952.  
  1953.  
  1954. INPUTS
  1955.       SEMLIST list;                 - a MemoryList to initialize.
  1956.       TABLENODE allocfunc(SEMLIST); - an allocation function that, given a
  1957.          d0                 a0         MemoryList, returns a MemoryNode
  1958.                                        structure as a header to 32
  1959.                                        elements to be doled out by
  1960.                                        AllocateItem().  If passed as NULL,
  1961.                                        the system allocates this for you.
  1962.       void freefunc(SEMLIST, TABLENODE);
  1963.                       a0        a1  - a free function that, given a
  1964.                                        MemoryList and a MemoryNode, frees
  1965.                                        the Node plus the 32 elements from
  1966.                                        the List.  If passed as NULL, the
  1967.                                        system frees the Node for you.
  1968.       long size                     - the size of each element.
  1969.  
  1970. OUTPUTS
  1971.       BOOL result;                  - result code
  1972.  
  1973.       The result code is a boolean indicating the success or failure of
  1974.       the function call.  A zero value indicates that an error occured.
  1975.  
  1976.  
  1977. RESULT
  1978.       The specified list is initilized, the first 32 elements are
  1979.       allocated, the semaphore is initialized, the memlst_semUse flag in
  1980.       the structure is set to TRUE, and the memlst_size set to the
  1981.       passed size.
  1982.  
  1983. BUGS
  1984.       none known.
  1985.  
  1986. NOTES
  1987.       It's not very flexible, but it's used for BinNodes, semaphores,
  1988.       and list internal structures.  It's got pretty good, but not
  1989.       fantastic, performance.  See PerfTest.
  1990.  
  1991. SEE ALSO
  1992.  
  1993.       AllocateItem()
  1994.       FreeItem()
  1995.       FreeTable()
  1996.  
  1997. NAME
  1998.       InitThread -- initializes the process object associated with the task.
  1999.  
  2000. SYNOPSIS
  2001.       task = InitThread( task )
  2002.        d0                 a0
  2003.  
  2004. FUNCTION
  2005.       This function initializes the passed task's object.
  2006.       It allocates necessary ports and messages that DJM() requires be
  2007.       present.
  2008.  
  2009.       When it is completed, it signals the parent task to resume.  The
  2010.       parent waits for this signal when the thread was started.
  2011.  
  2012.       You should allocate any thread-specific information after the call
  2013.       to WaitThread() and before the call to InitThread().  This allows
  2014.       the parent to safely shutdown, in case you cannot open, say, a
  2015.       required library.
  2016.  
  2017.       In case you do fail to gain the required resources, you should fail
  2018.       in the following way:
  2019.          {
  2020.             -clean-up-any-resources-you-allocated-
  2021.             DoJazzMethod((OBJECT)task->tc_UserData, NULL,
  2022.                          METHOD_META_REMOVE, METHOD_END);
  2023.             Signal(jproc->jp_parent, 1L << jproc->jp_parentSignal);
  2024.             return;
  2025.          }
  2026.  
  2027.       The parent will do the rest.
  2028.  
  2029.  
  2030. INPUTS
  2031.       struct Task *task; - the task to initialize.  MUST be non-NULL.
  2032.  
  2033. OUTPUTS
  2034.       struct Task *task; - same as passed in.
  2035.  
  2036.  
  2037. RESULT
  2038.       The resources required for synchronous methods are allocated, and
  2039.       the parent is allowed to resume processing.
  2040.  
  2041. BUGS
  2042.       none known.
  2043.  
  2044. NOTES
  2045.       You should NOT exit the thread until you receive a CTRL_C signal,
  2046.       and FindAttribute(task->tc_UserData, ATTR_JAZZPROCESS)->jp_parent is
  2047.       NULL.
  2048.  
  2049.       When you do exit, call RemoveThread() and then return from the
  2050.       top-level.
  2051.  
  2052. SEE ALSO
  2053.       WaitThread()
  2054.       RemoveThread()
  2055.       FindAttribute()
  2056.  
  2057. NAME
  2058.       InvalidateCache -- invalidates all cache entries for a class
  2059.  
  2060. SYNOPSIS
  2061.       InvalidateCache( meta )
  2062.                         a0
  2063.  
  2064. FUNCTION
  2065.       This function will invalidate all entries in the method's cache that
  2066.       refer to the passed class.  it must be called when a class is free'd.
  2067.  
  2068.  
  2069. INPUTS
  2070.       META *meta; - a class.
  2071.  
  2072. OUTPUTS
  2073.  
  2074.  
  2075. RESULT
  2076.       No more references to a defunct class exists in the method calling
  2077.       cache.
  2078.  
  2079. BUGS
  2080.       none known.
  2081.  
  2082. NOTES
  2083.  
  2084. SEE ALSO
  2085.       DJM()                            DoJazzMethod()
  2086.       SetMethodArgs()
  2087.       AddMethods()
  2088.       DestroyMethodTable()
  2089.       FindMethodHandle()
  2090.       BlockMethod()
  2091.       RemoveAllPatches()
  2092.       SetupMethodTags()
  2093.  
  2094. NAME
  2095.       IpcItemTransfer -- Transfers a resource from message to server.
  2096.  
  2097. SYNOPSIS
  2098.       IpcItemTransfer( msg, num )
  2099.                         a0   d0
  2100.  
  2101. FUNCTION
  2102.       This function will transfer the resource found in the num'th
  2103.       item in msg to the calling server.
  2104.  
  2105.       Basically, the IPC_ITEM_TRANSFER flag is cleared, and the
  2106.       IPC_SERVER_OWNED flag is set.
  2107.  
  2108.  
  2109. INPUTS
  2110.       struct IPCMessage *msg; - the (possibly NULL) message to xfer
  2111.                                  resources from.  If msg is NULL, no
  2112.                                  action is taken.
  2113.       long               num; - the item number where the resource is
  2114.                                  currently located.
  2115.  
  2116. OUTPUTS
  2117.       none
  2118.  
  2119.  
  2120. RESULT
  2121.       resource is no longer valid in the message.
  2122.  
  2123. BUGS
  2124.       none known.
  2125.  
  2126. NOTES
  2127.  
  2128. SEE ALSO
  2129.       IpcARGTransfer() macro
  2130.       ppipc.library documentation.  Not included in SHADOW, but available
  2131.       on a Fred Fish disk.
  2132.  
  2133. NAME
  2134.       JunkIPCMessage -- Frees a message allocated by MessageMaker
  2135.  
  2136. SYNOPSIS
  2137.       JunkIPCMessage( msg )
  2138.                        a0
  2139.  
  2140. FUNCTION
  2141.       This function will delete an IPCMessage, releasing all resources
  2142.       which have not been IpcItemTransfer()'d.
  2143.  
  2144.       The message itself is also deleted.
  2145.  
  2146.       Message should have been allocated by MessageMaker.
  2147.  
  2148.  
  2149. INPUTS
  2150.       struct IPCMessage *msg; - the message to delete.
  2151.  
  2152. OUTPUTS
  2153.       none
  2154.  
  2155.  
  2156. RESULT
  2157.       One more message is gone.
  2158.  
  2159. BUGS
  2160.       none known.
  2161.  
  2162. NOTES
  2163.  
  2164. SEE ALSO
  2165.       MessageMaker()
  2166.       IpcItemTransfer()
  2167.  
  2168. NAME
  2169.       MessageMaker -- Creates a Message for the given MethodHandle & args.
  2170.  
  2171. SYNOPSIS
  2172.       msg = MessageMaker( handle, args )
  2173.        d0                   a0     a1
  2174.  
  2175. FUNCTION
  2176.       This function will create a ppipc message that MessageParse()
  2177.       and ParseJazzMessage() can unroll in order to call a method
  2178.       asynchronously across tasks.
  2179.  
  2180.       Full resource tracking is done, and all resources are freed
  2181.       during the JunkIPCMessage() call, unless an IpcItemTransfer()
  2182.       was performed for that resource's item.
  2183.  
  2184.       IpcItemTransfer should be done during METHOD_META_DESTROY,
  2185.       at the very least.
  2186.  
  2187.  
  2188. INPUTS
  2189.       struct MethodHandle *handle; - the method that the message should
  2190.                                       serve.  Set the low bit of the
  2191.                                       address if this is actually a ptr
  2192.                                       into a MethodHandle object as
  2193.                                       returned from PatcherClass INIT.
  2194.       void                 **args; - the arguments that should be placed,
  2195.                                       one by one, into the message
  2196.                                       structure.  Full resource
  2197.                                       tracking will be done for these
  2198.                                       arguments according to the
  2199.                                       MethodRef structure, so the message
  2200.                                       can be sent asynchronously.
  2201.  
  2202. OUTPUTS
  2203.       struct IPCMessage *msg; - The returned message.
  2204.  
  2205.  
  2206. RESULT
  2207.       A new message is constructed.
  2208.  
  2209. BUGS
  2210.       none known.
  2211.  
  2212. NOTES
  2213.  
  2214. SEE ALSO
  2215.       JunkIPCMessage()
  2216.       DropObject()
  2217.       SetMethodArgs()
  2218.       ParseJazzMessage()
  2219.       MessageParse()
  2220.  
  2221. NAME
  2222.       MessageParse -- Parses a message onto the stack.
  2223.  
  2224. SYNOPSIS
  2225.       value = MessageParse( msg )
  2226.         d0                   a0
  2227.  
  2228. FUNCTION
  2229.       This function will parse a message onto the stack according to the
  2230.       MethodRef structure as passed inside of the message.  The
  2231.       message must have exactly the right number of items, or bad
  2232.       things may happen.
  2233.  
  2234.       The Method is then called, and its return value returned in d0.
  2235.  
  2236.       There is also some magic which allows DJM() to be called as the
  2237.       function, so that methods which are forced ASYNC by the flags
  2238.       in an original DJM() call, actually work properly....
  2239.  
  2240.  
  2241. INPUTS
  2242.       struct IPCMessage *msg; - should be a valid message set up by
  2243.                                  MessageMaker().
  2244.  
  2245. OUTPUTS
  2246.       void *value; - the return value of the method call.
  2247.  
  2248.  
  2249. RESULT
  2250.       The METHOD is called.
  2251.  
  2252. BUGS
  2253.       none known.
  2254.  
  2255. NOTES
  2256.  
  2257. SEE ALSO
  2258.       MethodFuncParse()
  2259.       DJM()
  2260.       MessageMaker()
  2261.  
  2262. NAME
  2263.       MethodFuncParse -- Copies the stack arguments back to the stack.
  2264.  
  2265. SYNOPSIS
  2266.       return = MethodFuncParse( handle, object, class, args )
  2267.        d0/d1                      a2     d0       d1    a1
  2268.  
  2269. FUNCTION
  2270.       This function will copy the arguments found in args onto the stack,
  2271.       according to the MethodRef structure found in handle.
  2272.  
  2273.       Unlike MessageParse(), it must deal with missing arguments -- ie:
  2274.       it may encounter METHOD_END (0x80000001) before the end of the
  2275.       MethodRef argument array.  The missing arguments are NULL'd out,
  2276.       then it calls the method function, and returns d0/d1 as a double.
  2277.  
  2278.       D0 is what should normally be considered as the return value.
  2279.       DJM() is incapable of returning real doubles at the current time.
  2280.       D1 is used by DJM() for its METHOD_FLAG_CHECK_CONTINUE.
  2281.       ParseJazzMessage() has some magic for storing D1 away for
  2282.       synchronous method calls.
  2283.  
  2284.       The 'msg' parameter of all Methods is NULL'd by MethodFuncParse().
  2285.  
  2286.  
  2287. INPUTS
  2288.       struct MethodHandler *handle; - the method's handle
  2289.       OBJECT                object; - the object being called.
  2290.       META                  *class; - the class the method is defined in.
  2291.       void                  **args; - the (other) arguments to the
  2292.                                        function.
  2293.  
  2294. OUTPUTS
  2295.       double return; - the return value is usually considered D0, but D1
  2296.                         is used by DJM() for its _CONTINUE checking.
  2297.  
  2298.  
  2299. RESULT
  2300.       The METHOD was called.
  2301.  
  2302. BUGS
  2303.       none known.
  2304.  
  2305. NOTES
  2306.  
  2307. SEE ALSO
  2308.       MessageParse()
  2309.       DJM()
  2310.       ParseJazzMessage()
  2311.  
  2312. NAME
  2313.       ParseJazzMessage -- parses the three types of SHADOW messages
  2314.  
  2315. SYNOPSIS
  2316.       ParseJazzMessage( msg )
  2317.                          a0
  2318.  
  2319. FUNCTION
  2320.       This function parses the three types of messages that SHADOW
  2321.       programs can receive -- AMET, SMET and JAZZ.
  2322.  
  2323.       AMET message are asynchronous messages, and these message are
  2324.       correctly handled by MessageParse()
  2325.  
  2326.       SMET messages are synchronous message and these message are
  2327.       correctly handled by MethodFuncParse()
  2328.  
  2329.       JAZZ are message you can send.  The function pointer should be in
  2330.       the first element of the message, and the single argument to the
  2331.       function should be in the second argument.  No value is currently
  2332.       returned -- but if someone needs to, please let me know.  They are
  2333.       currently unused.  The message is returned when the function is
  2334.       finished.
  2335.  
  2336.  
  2337. INPUTS
  2338.       struct IPCMessage *msg; - a message sent to a SHADOW task's port.
  2339.  
  2340. OUTPUTS
  2341.       none
  2342.  
  2343.  
  2344. RESULT
  2345.       The correct function is called.
  2346.       Unknown messages are allowed to hang around unused.....
  2347.  
  2348. BUGS
  2349.       Does not handle unknown messages without replyports properly.
  2350.       So don't send them!
  2351.  
  2352. NOTES
  2353.  
  2354. SEE ALSO
  2355.       MessageParse()
  2356.       MethodFuncParse()
  2357.  
  2358. NAME
  2359.       PrepareAttrTags -- Prepares Attribute tags for class definition
  2360.  
  2361. SYNOPSIS
  2362.       num = PrepareAttrTags( tags, countptr, super )
  2363.        d0                     a0      d1      a1
  2364.  
  2365. FUNCTION
  2366.       This function is designed specifically because of the inherent
  2367.       trickiness of Metas.
  2368.  
  2369.       Under normal situations, the functionality of this function would be
  2370.       incorporated into AddAttributes().  Unfortunately, because Metas
  2371.       are their own classes, the size of the Meta depends on the
  2372.       definitions held in the defining AttributeTags.  Therefore, the Meta
  2373.       cannot be allocated until it knows the required size, it wouldn't
  2374.       know the size until the AddAttributes call, but it can't call
  2375.       AddAttributes until the Meta exists so that the AttributeTable
  2376.       pointer can be passed in.
  2377.  
  2378.       At anyrate, this function determines the number of new attribute
  2379.       there are (returned num) and the additional size that will be
  2380.       needed (by incrementing the *countptr for each new attribute).
  2381.  
  2382.       Attributes which are already contained within the super are
  2383.       cheerfully ignored.  Respecified Attributes are assumed to be
  2384.       attempts to redefine the default value, not to resoecify an
  2385.       attribute.
  2386.  
  2387.       You probably won't need to use this function, unless you are
  2388.       creating your own Meta or METHODs for Metas.
  2389.  
  2390.  
  2391. INPUTS
  2392.       ATTRIBUTE_TAG       tags[]; - optional pointer to a NULL terminated
  2393.                                      array of AttributeTags.
  2394.       long             *countptr; - initialized pointer to the long which
  2395.                                      will be incremented by the additional
  2396.                                      size required by the passed
  2397.                                      attributes.  If any attributes are
  2398.                                      redefined (from the super), the size
  2399.                                      will not be incremented for that
  2400.                                      attribute.
  2401.       META                *super; - optional pointer to a superclass.
  2402.  
  2403. OUTPUTS
  2404.       long                num; - number of new attributes (does not
  2405.                                   include attributes redefined from the
  2406.                                   passed super.
  2407.  
  2408.  
  2409. RESULT
  2410.       The countptr variable is incremented by the additional size, above
  2411.       and beyond the size of 'super', that the passed attribute tags would
  2412.       require.
  2413.  
  2414. BUGS
  2415.       none known.
  2416.  
  2417. NOTES
  2418.       *countptr MUST be initialized, probably to the size of the
  2419.       superClass, as the size of the superClass is not used in calculating
  2420.       the size in this function.
  2421.  
  2422. SEE ALSO
  2423.       AddAttributes()
  2424.       CopyDefaultAttributes()
  2425.       FreeAttributes()
  2426.       FindAttribute()
  2427.       FindAttrDefn()
  2428.  
  2429. NAME
  2430.       PSem -- procures the semaphore for the given address.
  2431.  
  2432. SYNOPSIS
  2433.       result = PSem( address, flags )
  2434.         d0             a0       d0
  2435.  
  2436. FUNCTION
  2437.       This function semaphores the given address dictated by the
  2438.       following flags:
  2439.  
  2440.              SHADOW_EXCLUSIVE_SEMAPHORE  0
  2441.              SHADOW_SHARED_SEMAPHORE     1
  2442.              SHADOW_ATTEMPT_SEMAPHORE    2
  2443.  
  2444.       If anyone else attempts to semaphore the same address (via PSem),
  2445.       the system takes appropriate action (according to the flags).
  2446.  
  2447.       if the system cannot allocate a sempahore object internally,
  2448.       a busy loop with a Delay(30) is used until it can.  You
  2449.       are guaranteed that, when PSem returns, you have a lock o
  2450.       the semaphore -- unless SHADOW_ATTEMPT_SEMAPHORE is used, in
  2451.       which case you must look at the return code.
  2452.  
  2453.  
  2454. INPUTS
  2455.       void *address; - Any address within the system.
  2456.       ULONG flags;   - one of the three flags above.
  2457.  
  2458. OUTPUTS
  2459.       BOOL result;   - result code for AttemptSemaphore.  Always TRUE
  2460.                        otherwise.
  2461.  
  2462.       The result code is a Boolean indicating the success or failure of
  2463.       the function call.  A zero value indicates that the AttemptSemaphore
  2464.       (when SHADOW_ATTEMPT_SEMAPHORE is passed) failed.
  2465.  
  2466.  
  2467. RESULT
  2468.       The specified semaphore action will have taken place.
  2469.  
  2470. BUGS
  2471.       none known.
  2472.  
  2473. NOTES
  2474.  
  2475.       Although it is not strictly necessary, you will undoutedly encounter
  2476.       bugs if the address on which you have a semaphore is freed before the
  2477.       semaphore is.  Mostly because another task may then allocate that
  2478.       address, and attempt a semaphore on it -- leading to unexpected
  2479.       deadly embrace conditions.
  2480.  
  2481.       The address passed need not point to an object, as the BinTree and
  2482.       List code require.
  2483.  
  2484. SEE ALSO
  2485.       From exec.library:
  2486.          ObtainSemaphore()       -- SHADOW_EXCLUSIVE_SEMAPHORE
  2487.          ObtainSemaphoreShared   -- SHADOW_SHARED_SEMAPHORE
  2488.          AttemptSemaphore()      -- SHADOW_ATTEMPT_SEMAPHORE
  2489.  
  2490.       VSem()
  2491.  
  2492. NAME
  2493.       QuickDropString -- Decrements the useCount of a known system string.
  2494.  
  2495. SYNOPSIS
  2496.       QuickDropString( string )
  2497.                          a2
  2498.  
  2499. FUNCTION
  2500.       This function decrements the useCount of a known system string.
  2501.       The passed string *must* be a pointer to a system string.
  2502.  
  2503.       If the useCount drops to zero, DropString is automatically called
  2504.       in order to delete the string object from the correct place in
  2505.       the system's string hash table.
  2506.  
  2507.       Therefore, only call QuickUseString when you think you will have
  2508.       more than one reference to them.  That allows QDS() to work
  2509.       fastest.
  2510.  
  2511. INPUTS
  2512.       char *string; - the string to lower the refcounts of the system string.
  2513.  
  2514. OUTPUTS
  2515.  
  2516. RESULT
  2517.       The given system string has had its useCount decremented.
  2518.  
  2519. BUGS
  2520.       none known.
  2521.  
  2522. NOTES
  2523.  
  2524. SEE ALSO
  2525.       UseString()
  2526.       QuickUseString()
  2527.       FindString()
  2528.       DropString()
  2529.  
  2530. NAME
  2531.       QuickUseString -- Increment the usage counter of a system string.
  2532.  
  2533. SYNOPSIS
  2534.       string = QuickUseString( string )
  2535.         d0                       a2
  2536.  
  2537. FUNCTION
  2538.       This function increments the system usage counter for a string
  2539.       that you already know is a system string.  This must be the
  2540.       *address* of the system string, not a buffer pointer equivalent.
  2541.  
  2542.       If you pass in a NULL, this function returns a NULL.
  2543.  
  2544.       You should UseString() whenever saving  a suitable string into
  2545.       a structure -- a matching DropString() will then deallocate the
  2546.       reference.  Under the appropriate conditions (mentioned above)
  2547.       you may use QuickUseString() to avoid the hash and binary search
  2548.       calls.
  2549.  
  2550.  
  2551. INPUTS
  2552.       char *string; - the system string whose useCount should be incremented
  2553.  
  2554. OUTPUTS
  2555.       char *string; - the system string.
  2556.  
  2557.       Exactly what was passed into it.
  2558.  
  2559.  
  2560. RESULT
  2561.       The system string's internal useCount is incremented
  2562.  
  2563. BUGS
  2564.       none known.
  2565.  
  2566. NOTES
  2567.       Don't pass in arbitrary buffer pointers or you may risk overwriting
  2568.       your stack, or memory.
  2569.  
  2570. SEE ALSO
  2571.       UseString()
  2572.       FindString()
  2573.       DropString()
  2574.       QuickDropString()
  2575.  
  2576. NAME
  2577.       RecurseBinTree -- Recursively call a function on each BinNode of an
  2578.                         AVLTREE
  2579.  
  2580. SYNOPSIS
  2581.       result = RecurseBinTree( bt, func, data, recurse )
  2582.         d0                     a0   a1    d0     d1
  2583.  
  2584. FUNCTION
  2585.       This function will recurse through the binary tree, calling func()
  2586.       for each object found with the parameters 'object key data', where
  2587.       object is the object in the binary tree, key is the key that the
  2588.       object is sorted on, and data is the data passed into the Recurse()
  2589.       call.
  2590.  
  2591.       If this func() ever returns non-NULL, the recursion is stopped, and
  2592.       the non_NULL return code is returned to the caller of RecurseBinTree.
  2593.  
  2594.       There are three different ways to recurse through a binary tree.
  2595.       The following flags are defined in shadow/bintree.h:
  2596.  
  2597.          SHADOW_RECURSE_INORDER     == 1
  2598.          SHADOW_RECURSE_PREORDER    == 2
  2599.          SHADOW_RECURSE_POSTORDER   == 3
  2600.  
  2601.       The order of the recursion is determined by these flags passed as
  2602.       the recurse parameter.  INORDER outputs the left children, then the
  2603.       root, then the right children.  PREORDER outputs the root, the left,
  2604.       then the right.  POSTORDER outputs the left, the right, then the
  2605.       root.
  2606.  
  2607.  
  2608. INPUTS
  2609.       AVLTREE *bt;                         - the binary tree to recurse
  2610.                                               over.
  2611.       void *(*func)(void *, ULONG, void *) - the function.  return value
  2612.                      a0      d0     a1       used below.  Return NULL to
  2613.                                              continue recursive calling,
  2614.                                              non-NULL to end recursive calls.
  2615.                                              Three parameters are:
  2616.                                               object, key, data.
  2617.                                              See above.
  2618.       void *data                           - the passed data
  2619.       long recurse                         - the recurse type flag.
  2620.  
  2621. OUTPUTS
  2622.  
  2623.       void *result; - returns non-NULL of func() if func() ever returns
  2624.                       non-NULL.  Else returns NULL.
  2625.  
  2626. RESULT
  2627.       func() called for each element in the binary tree.
  2628.  
  2629. BUGS
  2630.       It calls a semaphore EXCLUSIVE on the AVLTREE, NOT SHARED!
  2631.       Sigh, I wish Exec knew enough to be able to get a SHARED
  2632.       semaphore on something you already had an EXCLUSIVE semaphore
  2633.       on.
  2634.  
  2635. NOTES
  2636.       Do NOT RemoveBinNode() the object from the binary tree that you
  2637.       are recursing through in the passed function.  AND do not call any
  2638.       methods that would....
  2639.  
  2640.       Remember that the keys are sorted unsigned, not signed.
  2641.  
  2642. SEE ALSO
  2643.       AddNodeBinTree()           AddNodeWatchedBinTree()
  2644.       AddNodeStringBinTree()     AddNodeStringWatchedBinTree()
  2645.       FindBinNode()              RemoveWatchedBinNode()
  2646.       FreeAllNodesBinTree()      RemoveStringWatchedBinNode()
  2647.       RemoveBinNode()
  2648.       RemoveStringBinNode()
  2649.  
  2650. NAME
  2651.       RemoveAllPatches -- Removes all Patches from a given class.
  2652.  
  2653. SYNOPSIS
  2654.       RemoveAllPatches( meta )
  2655.                          a0
  2656.  
  2657. FUNCTION
  2658.       This function will remove all of the method patches of a given
  2659.       class.  This should be executed when deleting a class in which
  2660.       methods could be patched.
  2661.  
  2662.       It is currently called in the META_DESTROY of the metaclass and the
  2663.       metaCluster.
  2664.  
  2665.       Because of this, it is IMPOSSIBLE to patch the METHOD_META_DESTROY
  2666.       method for any metas, because they are their own classes -- the
  2667.       function that would call RemoveALlPatches may be in a method-chain,
  2668.       which would not be valid when control returned to DJM() to continue
  2669.       the method chain.  This would be confusing, at best.... :(
  2670.  
  2671.  
  2672. INPUTS
  2673.       META  meta; - the class to delete all the patches from.
  2674.  
  2675. OUTPUTS
  2676.  
  2677.  
  2678. RESULT
  2679.  
  2680. BUGS
  2681.       none known.
  2682.  
  2683. NOTES
  2684.  
  2685. SEE ALSO
  2686.       DJM()                            DoJazzMethod()
  2687.       InvalidateCache()
  2688.       SetMethodArgs()
  2689.       AddMethods()
  2690.       DestroyMethodTable()
  2691.       FindMethodHandle()
  2692.       BlockMethod()
  2693.       SetupMethodTags()
  2694.  
  2695. NAME
  2696.       RemoveAutoResource -- Removes resource from process' tracking tree.
  2697.  
  2698. SYNOPSIS
  2699.       resource = RemoveAutoResource( task, resource, key )
  2700.          d0                           a0      d0     a1
  2701.  
  2702.  
  2703. FUNCTION
  2704.       The resource, which is found using the resource/key pair, is
  2705.       removed from the process' ATTR_RESOURCETREE and returned back
  2706.       to your control.  No METHOD_META_REMOVE is done, and you must
  2707.       DropObject() the resource which is returned.
  2708.  
  2709.       Task parameter is optional and defaults to the current task.
  2710.       Resource parameter is optional, and defaults to whatever
  2711.       resource is found using the provided key.  (If key >255, then
  2712.       key is assumed to be a string, and is handled accordingly.)
  2713.  
  2714. INPUTS
  2715.       OBJECT                 task; - The optional task object that performs
  2716.                                       the auto-tracking.  If not specified,
  2717.                                       assumes current taskObject.
  2718.       OBJECT             resource; - The optional object being auto-tracked.
  2719.                                       If no resource, then resource is
  2720.                                       looked up on the binary tree using
  2721.                                       the value in key.
  2722.       char                   *key; - The name of the resource.  Resources
  2723.                                       without names are stored by their
  2724.                                       addresses.  Name addresses of 0-255
  2725.                                       are reserved for priority freeing.
  2726.                                       Resources are freed in INCREASING
  2727.                                       key order.
  2728.  
  2729. OUTPUTS
  2730.       OBJECT             resource; - The resource as found.  You must
  2731.                                       DropObject() the returned resource
  2732.                                       when you are no longer interested in
  2733.                                       it.
  2734.  
  2735. RESULT
  2736.  
  2737. BUGS
  2738.       none known.
  2739.  
  2740. NOTES
  2741.  
  2742. SEE ALSO
  2743.       AddAutoResource()
  2744.       DropObject()
  2745.  
  2746. NAME
  2747.       RemoveBinNode -- Removes a node from a binary tree
  2748.  
  2749. SYNOPSIS
  2750.       result = RemoveBinNode( bt, object, key )
  2751.         d0                    a0    a1    d0
  2752.  
  2753. FUNCTION
  2754.       This function will remove an object from the binary tree,
  2755.       dropping it via DropObject().
  2756.  
  2757.       The object pointer is required to verify the correct node is
  2758.       being removed (in case nodes with the same key exist in the
  2759.       same tree).
  2760.  
  2761.  
  2762. INPUTS
  2763.       AVLTREE               *bt; - a pointer to the root of the binary tree.
  2764.       OBJECT             object; - the object to add into the tree.
  2765.       ULONG                 key; - the key value to insert on.
  2766.  
  2767. OUTPUTS
  2768.       BOOL result
  2769.  
  2770.       returns FALSE on failure to remove.
  2771.  
  2772.  
  2773. RESULT
  2774.       The object exists in the tree at least one fewer times than it did.
  2775.  
  2776. BUGS
  2777.       none known.
  2778.  
  2779. NOTES
  2780.       Remember that the keys are sorted unsigned, not signed.
  2781.  
  2782. SEE ALSO
  2783.       DropObject()
  2784.  
  2785.       AddNodeBinTree()           AddNodeWatchedBinTree()
  2786.       AddNodeStringBinTree()     AddNodeStringWatchedBinTree()
  2787.       FindBinNode()              RemoveWatchedBinNode()
  2788.       FreeAllNodesBinTree()      RemoveStringWatchedBinNode()
  2789.       RecurseBinTree()
  2790.       RemoveStringBinNode()
  2791.  
  2792. NAME
  2793.       RemoveClassWatcher -- Removes a watcher from all classes.
  2794.  
  2795. SYNOPSIS
  2796.       RemoveClassWatcher( watchName, director, name, class )
  2797.                               a0        a1      d0     d1
  2798.  
  2799. FUNCTION
  2800.       This function will remove the director from the class' attribute
  2801.       watching SList of the passed name.  This is a low-level routine.
  2802.       You should call the DIRECTOR CLASS routines instead.  See browser.c,
  2803.       or ShadowLibMethods.doc.
  2804.  
  2805.  
  2806. INPUTS
  2807.       char             *watchName; - the attribute name that is watched
  2808.       OBJECT             director; - the director to Remove from the
  2809.                                       attribute watching SList.
  2810.       char                  *name; - the name of the watcher.
  2811.       META                  class; - the class to remove the watcher from.
  2812.  
  2813. OUTPUTS
  2814.       none
  2815.  
  2816. RESULT
  2817.       The director is removed from the class' watch list.
  2818.  
  2819. BUGS
  2820.       none known.
  2821.  
  2822. NOTES
  2823.  
  2824. SEE ALSO
  2825.       AddWatcherNode()
  2826.       RemoveWatcherNode()
  2827.       AddClassWatcher()
  2828.  
  2829. NAME
  2830.       RemoveCurrentProgram -- removes the current process from the system.
  2831.  
  2832. SYNOPSIS
  2833.       RemoveCurrentProgram( semaphore )
  2834.                                a0
  2835.  
  2836. FUNCTION
  2837.       This function is the counterpart of InitOOProgram().  It removes an
  2838.       AmigaDOS loaded program from the system so that that program can exit
  2839.       safely.
  2840.  
  2841.       This is SOP for cleaning up a -program-.
  2842.  
  2843.       RemoveCurrentProgram() waits for no other process to own a reference
  2844.       to the process associated with the program.  While it does this, it
  2845.       handles messages on jp_port and jp_replyPort (struct JazzProcess).
  2846.  
  2847.       This function sends a METHOD_META_REMOVE to the processObject, waits
  2848.       on the process' jp_port and jp->replyPort for messages (which it
  2849.       manages by taking everything off the list, handling the messages,
  2850.       then checking for more signals).  It also waits for a ^C and then
  2851.       checks that jp_parent is NULL.
  2852.  
  2853.       A program may create many threads on itself.  When INIT'ing a process
  2854.       object, one parameter that the programmer can pass is a SEMF.  This
  2855.       is a pointer to a semaphore that is passed in as NP_ExitData.  It is
  2856.       ObtainShared() during the waitThread() call, and Release()'d when the
  2857.       thread is done executing.
  2858.  
  2859.       RemoveCurrentProgram() waits on this semaphore until all threads
  2860.       have exited before removing the program's process object.
  2861.  
  2862.       A NULL semaphore is dealt with appropriately.
  2863.  
  2864.  
  2865. INPUTS
  2866.       struct SignalSemaphore *semaphore; - the thread semaphore
  2867.  
  2868. OUTPUTS
  2869.  
  2870.  
  2871. RESULT
  2872.       The program's process object is removed and associated ports freed.
  2873.  
  2874. BUGS
  2875.       none known.
  2876.  
  2877. NOTES
  2878.  
  2879. SEE ALSO
  2880.       InitOOProgram()
  2881.  
  2882. NAME
  2883.       RemoveSListNode -- removes a node from a prioritized, singly-linked
  2884.                           list.
  2885.  
  2886. SYNOPSIS
  2887.       result = RemoveSListNode( list, object, name )
  2888.         d0                       a0     a1     d1
  2889.  
  2890. FUNCTION
  2891.       This function removes an object from a singly linked list with the
  2892.       given name.
  2893.  
  2894.  
  2895. INPUTS
  2896.       SList               *list; - a pointer to the list from which to
  2897.                                     remove the object.
  2898.       OBJECT             object; - the object to remove.
  2899.       char                *name; - the name it was added as.
  2900.  
  2901.  
  2902. OUTPUTS
  2903.       BOOL result; - result code
  2904.  
  2905.       returns FALSE if can't find the node to Remove.
  2906.  
  2907.  
  2908. RESULT
  2909.       One fewer nodes are on the list.
  2910.  
  2911. BUGS
  2912.       none known.
  2913.  
  2914. NOTES
  2915.  
  2916. SEE ALSO
  2917.       FindNodePriInSList()                AddWatchedSListNode()
  2918.       AddSListNode()                      RemoveWatchedSListNode()
  2919.  
  2920. NAME
  2921.       RemoveStringBinNode -- Removes a node from a binary tree.
  2922.  
  2923. SYNOPSIS
  2924.       result = RemoveStringBinNode( bt, object, name )
  2925.                                     a0    a1     d1
  2926.  
  2927. FUNCTION
  2928.       This function will remove an object from the binary tree,
  2929.       dropping it via DropObject(), and dropping the string
  2930.       via DropString (if found).
  2931.  
  2932.       The object pointer is required to verify that the correct node is
  2933.       being removed (in case nodes with the same key exist in the same
  2934.       tree).
  2935.  
  2936.  
  2937. INPUTS
  2938.       AVLTREE    *bt; - a pointer to the root of the binary tree.
  2939.       OBJECT  object; - the object to add into the tree.
  2940.       char     *name; - the name to insert on.
  2941.  
  2942. OUTPUTS
  2943.       BOOL result
  2944.  
  2945.       returns FALSE on failure to remove.
  2946.  
  2947.  
  2948. RESULT
  2949.       The object exists in the tree at least one fewer times than it did.
  2950.  
  2951. BUGS
  2952.       none known.
  2953.  
  2954. NOTES
  2955.       Yes, that's d1, not d0 for 'name' parameter.
  2956.  
  2957. SEE ALSO
  2958.       DropObject                 DropString
  2959.  
  2960.       AddNodeBinTree()           AddNodeWatchedBinTree()
  2961.       AddNodeStringBinTree()     AddNodeStringWatchedBinTree()
  2962.       FindBinNode()              RemoveWatchedBinNode()
  2963.       FreeAllNodesBinTree()      RemoveStringWatchedBinNode()
  2964.       RecurseBinTree()
  2965.       RemoveBinNode()
  2966.  
  2967. NAME
  2968.       RemoveStringWatchedBinNode -- Removes an object from the given
  2969.                                      binary tree
  2970.  
  2971. SYNOPSIS
  2972.       result = RemoveStringWatchedBinNode( bt, object, name )
  2973.         d0                                 a0    a1     d1
  2974.  
  2975. FUNCTION
  2976.       This function will remove an object from the watched binary tree,
  2977.       dropping it via DropObject(), and dropping the string
  2978.       via DropString (if found).
  2979.  
  2980.       The object pointer is required to verify the correct node is
  2981.       being removed (in case nodes with the same key exist in the
  2982.       same tree).
  2983.  
  2984.       If any parties are interested, WatcherDispatch is called with
  2985.       W_INSERT_NODE
  2986.  
  2987.  
  2988. INPUTS
  2989.       W_AVLTREE      *bt; - a pointer to the root of the watched binary
  2990.                              tree.
  2991.       OBJECT      object; - the object to add into the tree.
  2992.       char         *name; - the name to insert on.
  2993.  
  2994. OUTPUTS
  2995.       BOOL result
  2996.  
  2997.       returns FALSE on failure to remove.
  2998.  
  2999.  
  3000. RESULT
  3001.       The object exists in the tree at least one fewer times than it did.
  3002.  
  3003. BUGS
  3004.       none known.
  3005.  
  3006. NOTES
  3007.  
  3008. SEE ALSO
  3009.       DropObject                 DropString
  3010.  
  3011.       AddNodeBinTree()           AddNodeWatchedBinTree()
  3012.       AddNodeStringBinTree()     AddNodeStringWatchedBinTree()
  3013.       FindBinNode()              RemoveWatchedBinNode()
  3014.       FreeAllNodesBinTree()
  3015.       RecurseBinTree()
  3016.       RemoveBinNode()
  3017.       RemoveStringBinNode()
  3018.  
  3019. NAME
  3020.       RemoveThread -- removes a previously initialized thread.
  3021.  
  3022. SYNOPSIS
  3023.       RemoveThread( object )
  3024.                       a0
  3025.  
  3026. FUNCTION
  3027.       This function deallocates the resources that were allocated by
  3028.       InitThread().  It should not be called until InitThread() has
  3029.       returned, a CTRL_C received by the thread, and the JazzProcess'
  3030.       jp_parent pointer (found in the taskObject -- see InitThread())
  3031.       is NULL.
  3032.  
  3033.       The process' ATTR_RESOURCETREE and the process' ATTR_RESOURCESTACK
  3034.       are both freed -- meaning that all resources on that tree and on
  3035.       that list are sent a METHOD_META_REMOVE, and then all resources on
  3036.       that tree and list are removed from the tree/list.
  3037.  
  3038.  
  3039. INPUTS
  3040.       OBJECT object; - the object of the task --
  3041.                         FindTask(NULL)->tc_UserData
  3042.  
  3043. OUTPUTS
  3044.       none
  3045.  
  3046.  
  3047. RESULT
  3048.       Resources for the thread are released.
  3049.  
  3050. BUGS
  3051.       none known.
  3052.  
  3053. NOTES
  3054.       Follows the conventions of exitting properly!  So call it!
  3055.  
  3056. SEE ALSO
  3057.       InitThread()
  3058.       RemoveThread()
  3059.  
  3060. NAME
  3061.       RemoveWatchedBinNode -- Removes an object from the watched binary
  3062.                                tree.
  3063.  
  3064. SYNOPSIS
  3065.       result = RemoveWatchedBinNode( bt, object, key )
  3066.         d0                           a0    a1    d0
  3067.  
  3068. FUNCTION
  3069.       This function will remove an object from the watched binary tree,
  3070.       dropping it via DropObject().
  3071.  
  3072.       The object pointer is required to verify the correct node is
  3073.       being removed (in case nodes with the same key exist in the
  3074.       same tree).
  3075.  
  3076.       If any parties are interested, WatcherDispatch is called with
  3077.       W_INSERT_NODE
  3078.  
  3079.  
  3080. INPUTS
  3081.       W_AVLTREE             *bt; - a pointer to the root of the watched
  3082.                                     binary tree.
  3083.       OBJECT             object; - the object to add into the tree.
  3084.       ULONG                 key; - the key value to insert on.
  3085.  
  3086. OUTPUTS
  3087.       BOOL result
  3088.  
  3089.       returns FALSE on failure to Remove.
  3090.  
  3091. RESULT
  3092.       The object exists in the tree at least one fewer times than it did.
  3093.  
  3094.       Remember that the keys are sorted unsigned, not signed.
  3095.  
  3096. BUGS
  3097.       none known.
  3098.  
  3099. NOTES
  3100.  
  3101. SEE ALSO
  3102.       DropObject()
  3103.  
  3104.       AddNodeBinTree()           AddNodeWatchedBinTree()
  3105.       AddNodeStringBinTree()     AddNodeStringWatchedBinTree()
  3106.       FindBinNode()
  3107.       FreeAllNodesBinTree()      RemoveStringWatchedBinNode()
  3108.       RecurseBinTree()
  3109.       RemoveBinNode()
  3110.       RemoveStringBinNode()
  3111.  
  3112. NAME
  3113.       RemoveWatchedSListNode -- removes a node from a watched, prioritized
  3114.                                  singly-linked list.
  3115.  
  3116. SYNOPSIS
  3117.       result = RemoveWatchedSListNode( list, object, name )
  3118.         d0                              a0     a1     d1
  3119.  
  3120. FUNCTION
  3121.       This function removes an object from a watched, singly-linked list
  3122.       with the given name.
  3123.  
  3124.       If any parties are interested, WatcherDispatch is called with
  3125.       W_REMOVE_NODE for the flag parameter.
  3126.  
  3127.  
  3128. INPUTS
  3129.       W_SLIST              list; - a pointer to the list from which to
  3130.                                     remove the object.
  3131.       OBJECT             object; - the object to remove.
  3132.       char                *name; - the name it was added as.
  3133.  
  3134.  
  3135. OUTPUTS
  3136.       BOOL result; - result code
  3137.  
  3138.       returns FALSE if can't Remove.
  3139.  
  3140.  
  3141. RESULT
  3142.       One fewer nodes are on the list.
  3143.  
  3144. BUGS
  3145.       none known.
  3146.  
  3147. NOTES
  3148.  
  3149. SEE ALSO
  3150.       FindNodePriInSList()                AddWatchedSListNode()
  3151.       AddSListNode()
  3152.       RemoveSListNode()
  3153.  
  3154. NAME
  3155.       RemoveWatcherNode -- Removes a watcher to the watched variable
  3156.  
  3157. SYNOPSIS
  3158.       result = RemoveWatcherNode( wv, node, name )
  3159.                                   a0   a1    d1
  3160.  
  3161. FUNCTION
  3162.       This removes a watcher node from a watched variable.  This
  3163.       is a low-level routine.  You should call the DIRECTOR CLASS
  3164.       routines instead.  See browser.c, or ShadowLibMethods.doc.
  3165.  
  3166.  
  3167. INPUTS
  3168.       W_VALUE             *wv; - the watched variable being watched.
  3169.       OBJECT             node; - the director to remove from the watch
  3170.                                   list.
  3171.       char              *name; - the name of the watcher.
  3172.  
  3173. OUTPUTS
  3174.       BOOL result
  3175.  
  3176.       returns FALSE if failed to Remove.
  3177.  
  3178.  
  3179. RESULT
  3180.       The director is removed from the watch list.
  3181. BUGS
  3182.       none known.
  3183.  
  3184. NOTES
  3185.  
  3186. SEE ALSO
  3187.       AddWatcherNode()
  3188.       AddClassWatcher()
  3189.       RemoveClassWatcher()
  3190.  
  3191. NAME
  3192.       SetMethodArgs -- parses a MethodRef structure for method creation.
  3193.  
  3194. SYNOPSIS
  3195.       SetMethodArgs( mh, args )
  3196.                      a0   a1
  3197.  
  3198. FUNCTION
  3199.       This function parses out the MethodRef structure.
  3200.       It sets up the mh_num, mh_size and mh_args field in the
  3201.       passed MethodHandle structure.
  3202.  
  3203.       If the function returns a variable that needs to be kept
  3204.       track of, the last MethodRef structure (whose mr_tag should be
  3205.       zero) in the array should contain information for async. method
  3206.       sends to safely deallocate or otherwise resource track the
  3207.       returned value.
  3208.  
  3209.       Valid returns are:
  3210.        SHADOW_RETURN_BLANK   0
  3211.        SHADOW_RETURN_OBJECT  1
  3212.        SHADOW_RETURN_STRING  2
  3213.        SHADOW_RETURN_PORT    3
  3214.        SHADOW_RETURN_TAGL    4
  3215.        SHADOW_RETURN_PTR     5
  3216.  
  3217.       These values should be stored in the mr_size field of the last
  3218.       MethodRef array item..
  3219.  
  3220.       for SHADOW_RETURN_PTR, the size of the pointer should be stored
  3221.       in the mr_flags field of the same item.
  3222.  
  3223.       Normally, the system supports a number of mr_tag values:
  3224.          'MRFO':
  3225.             used for object values which add sizeof(struct CoreObject) to
  3226.                   the passed object pointer.
  3227.             mr_size should be four
  3228.             mr_flags ignored.
  3229.  
  3230.          'JOBJ':
  3231.             Used for an object.
  3232.             mr_size should be four
  3233.             mr_flags should be one of:
  3234.                SHADOW_OBJECT
  3235.                SHADOW_CLASSLESSOBJECT
  3236.                SHADOW_META
  3237.                SHADOW_CLASS,
  3238.                SHADOW_CLUSTER
  3239.                SHADOW_COMPOSITE
  3240.              though this is more for peace of mind than necessity.
  3241.  
  3242.          'JMSG':
  3243.             Used for a message creted by MessageMaker()
  3244.             mr_size should be four
  3245.             mr_flags should be zero
  3246.  
  3247.          'JSTR':
  3248.             Used for a system string.
  3249.             mr_size should be four
  3250.             mr_flags should be zero
  3251.  
  3252.          'PORT':
  3253.             Used for a ppipc port.
  3254.             mr_size should be four
  3255.             mr_flags should be ???? <-- anything you like!
  3256.  
  3257.          'TAGL':
  3258.             Used for a NULL terminated array.
  3259.             mr_size should be four.
  3260.             mr_flags should be the size of each array item
  3261.  
  3262.          'RTRN':
  3263.             reserved by the system, don't use.
  3264.          'APTR'
  3265.             a pointer to some memory.
  3266.             mr_size should be four.
  3267.             mr_flags should be zero if you don't want to copy the data to
  3268.              another block when sending async., or should be the size of
  3269.              the data pointed to if you do.
  3270.  
  3271.          Create you own 4 character constant:
  3272.             mr_size should be an even number -- you can pass arbitrarily
  3273.              large structures on the stack, this way.
  3274.             mr_flags ignored.
  3275.  
  3276.  
  3277. INPUTS
  3278.       struct MethodHandle *mh; - a MethodHandle being initialized.
  3279.       METHOD_REF       args[]; - the (optional, and NULL-terminated)
  3280.                                   MethodRef array for this handle.
  3281.  
  3282. OUTPUTS
  3283.  
  3284.  
  3285. RESULT
  3286.       mh->mh_args, mh-Mh_num, mh->mh_size fields are set up properly.
  3287.  
  3288. BUGS
  3289.       none known.
  3290.  
  3291. NOTES
  3292.  
  3293. SEE ALSO
  3294.       DJM()                            DoJazzMethod()
  3295.       InvalidateCache()
  3296.       AddMethods()
  3297.       DestroyMethodTable()
  3298.       FindMethodHandle()
  3299.       BlockMethod()
  3300.       RemoveAllPatches()
  3301.       SetupMethodTags()
  3302.  
  3303. NAME
  3304.       SetupMethodTags -- defines all methods in the MethodTag array as
  3305.                            being run by a certain process object, and
  3306.                            being owned by a certain object.
  3307.  
  3308. SYNOPSIS
  3309.       SetupMethodTags( tags, procObject, defnObject )
  3310.                         a1       d0          d1
  3311.  
  3312. FUNCTION
  3313.       This function will initialize the (required, NULL-terminated) tags
  3314.       array so that each method is located in a particular defnObject and
  3315.       wants to be called in a partiular procObject's process.
  3316.  
  3317.       For instance, gui methods may exist in a libraryObject (ie: a
  3318.       library) and want to be run by the guiProcObject.
  3319.  
  3320.       If passed objects of -1, the current task object is used.
  3321.          [That is; FindTask(NULL)->tc_UserData]
  3322.  
  3323.  
  3324. INPUTS
  3325.       METHOD_TAG             tags[]; - NULL-terminated MethodTag array.
  3326.       OBJECT             procObject; - the process object in which to run
  3327.                                         the methods.
  3328.       OBJECT             defnObject; - the object that "contains" the
  3329.                                         definition of the MethodREF -and-
  3330.                                         the function code.
  3331.  
  3332. OUTPUTS
  3333.  
  3334.  
  3335. RESULT
  3336.  
  3337. BUGS
  3338.       none known.
  3339.  
  3340. NOTES
  3341.       This is what guarantees that the function and MethodRef pointers
  3342.       remain valid as long as a method could call that function.
  3343.       The MethodRef structure is NOT copied when stored into the
  3344.       MethodHandler structure (the information in MethodTags and
  3345.       AttributeTags is).
  3346.  
  3347. SEE ALSO
  3348.       DJM()                            DoJazzMethod()
  3349.       InvalidateCache()
  3350.       SetMethodArgs()
  3351.       AddMethods()
  3352.       DestroyMethodTable()
  3353.       FindMethodHandle()
  3354.       BlockMethod()
  3355.       RemoveAllPatches()
  3356.  
  3357. NAME
  3358.       UseObject -- resource tracking for shadow objects.
  3359.  
  3360. SYNOPSIS
  3361.       object = UseObject( object )
  3362.         d0                  a0
  3363.  
  3364. FUNCTION
  3365.       This function increments the object's cob_useCount field.
  3366.       You should Use an object whenever you save a pointer into
  3367.       a structure.
  3368.  
  3369.  
  3370. INPUTS
  3371.       OBJECT      object; - the object to effect the change upon.
  3372.                              If NULL, nothing happens
  3373.  
  3374. OUTPUTS
  3375.       OBJECT      object; - the same as the object sent in.
  3376.  
  3377.  
  3378. RESULT
  3379.       object's cob_object is incremented.
  3380.  
  3381. BUGS
  3382.       none known.
  3383.  
  3384. NOTES
  3385.  
  3386. SEE ALSO
  3387.       DropObject()
  3388.  
  3389. NAME
  3390.       UseString -- gets a system-wide address for a given string.
  3391.  
  3392. SYNOPSIS
  3393.       string = UseString( buffer )
  3394.         d0                  a2
  3395.  
  3396. FUNCTION
  3397.       Shadow uses a system very much similar to the NeXT's -- a system-
  3398.       wide repository for string addresses.
  3399.  
  3400.       Strings are hashed into a 1024 table entry and chained onto sorted
  3401.       binary trees.  The string which is returned is guaranteed to be a
  3402.       unique string address for the passed buffer.
  3403.  
  3404.       The passed buffer's address is *NOT* used as the system string
  3405.       address, so it can be a temporary stack-allocated buffer.  The
  3406.       system string is created when a first UseString() is called for
  3407.       a given buffer.  On the second UseString() call for the same buffer,
  3408.       the same string address will be returned, and an internal counter
  3409.       which tracks the string usage is incremented.
  3410.  
  3411.       These system strings may *NOT* be mangled, they are read-only.
  3412.       They are particularly good for static data that you wish to do
  3413.       searches on, as system-strings have a unique address, strcmp() is
  3414.       unnecessary, merely compare the string addresses.  They are used
  3415.       internally for BinNode strings, Method names, attribute names,
  3416.       class names, etc.
  3417.  
  3418.  
  3419. INPUTS
  3420.       char *buffer; - the string to retrieve a unique system pointer for.
  3421.                       Given a NULL input, will return NULL.
  3422.  
  3423. OUTPUTS
  3424.       char *string; - the unique string as returned by the system.  A NULL
  3425.                       signals an error.
  3426.  
  3427.  
  3428. RESULT
  3429.       Either a new system string is created, and the buffer copied into
  3430.       it, or an old system string is retrieved and its usage counter
  3431.       incremented.
  3432.  
  3433. BUGS
  3434.       none known.
  3435.  
  3436. NOTES
  3437.       The buffer should be word-aligned for fastest access.
  3438.  
  3439. SEE ALSO
  3440.       QuickUseString()
  3441.       FindString()
  3442.       DropString()
  3443.       QuickDropString()
  3444.  
  3445. NAME
  3446.       VSem -- Vacate a semaphore
  3447.  
  3448. SYNOPSIS
  3449.       VSem( address )
  3450.               a0
  3451.  
  3452. FUNCTION
  3453.       This function does the equivalent of a ReleaseSemaphore on the
  3454.       given address.
  3455.  
  3456.       Every PSem() should be matched with a VSem(), except for PSem()s
  3457.       where a SHADOW_ATTEMPT_SEMAPHORE failed, in which case VSem()
  3458.       should NOT be called.
  3459.  
  3460.  
  3461. INPUTS
  3462.       void *address; - Any address in the system.
  3463.  
  3464. OUTPUTS
  3465.  
  3466.  
  3467. RESULT
  3468.       The semaphore will be released (vacated), and the semaphore object
  3469.       freed if no longer needed.
  3470.  
  3471. BUGS
  3472.       none known.
  3473.  
  3474. NOTES
  3475.  
  3476. SEE ALSO
  3477.       From exec.library:
  3478.          ReleaseSemaphore()
  3479.  
  3480.       PSem()
  3481.  
  3482. NAME
  3483.       WaitThread -- synchronizes thread startup.
  3484.  
  3485. SYNOPSIS
  3486.       task = WaitThread( )
  3487.        d0
  3488.  
  3489. FUNCTION
  3490.       This function synchronizes the startup procedures for thread
  3491.       initialization.  After a thread starts, there a number of things
  3492.       that the parent would like to be able to do.  This function
  3493.       (which is required in the startup function you pass to the
  3494.        METHOD_META_INIT for a process object) allows the parent to
  3495.       complete its task BEFORE your thread is actually run.
  3496.  
  3497.  
  3498. INPUTS
  3499.       none
  3500.  
  3501. OUTPUTS
  3502.       struct Task *task; - the pointer to your task.
  3503.  
  3504.  
  3505. RESULT
  3506.       parent has now filled in the task's object, so you can retrieve it
  3507.       from task->tc_UserData
  3508.  
  3509. BUGS
  3510.       none known.
  3511.  
  3512. NOTES
  3513.  
  3514. SEE ALSO
  3515.       InitThread()
  3516.       RemoveThread()
  3517.  
  3518. NAME
  3519.       WatcherDispatch -- Dispatches all notification methods.
  3520.  
  3521. SYNOPSIS
  3522.       WatcherDispatch( flag, wv, first, second )
  3523.                         d0   a0    a1     d1
  3524.  
  3525. FUNCTION
  3526.       This function dispatches notification to all parties that
  3527.       have added themselves either to the WatchedVariable in
  3528.       question, or to the SList that wv->wv_firstClass points to.
  3529.  
  3530.       Watched Values are a tricky subject which will require a lot
  3531.       more than a simple AutoDoc note to explain them.
  3532.  
  3533.       Please see examples in browser.c for now, or refer to the DIRECTOR
  3534.       CLASS documentation in ShadowLibMethods.doc.
  3535.  
  3536.  
  3537. INPUTS
  3538.       long    flag; - Informs of the type of change made to the value:
  3539.                         W_CHANGE_ZERO      1
  3540.                         W_CHANGE_NON_ZERO  2
  3541.                         W_INSERT_WATCHER  40
  3542.                         W_REMOVE_WATCHER  24
  3543.                         W_INSERT_NODE     32
  3544.                         W_REMOVE_NODE     16
  3545.       W_VALUE  *wv; - the watchedValue that was changed.
  3546.       void  *first; - the object that was added to the list/AVLTREE, or
  3547.                        the value that the variable was changed to.
  3548.       void *second; - the name or key for the new node in the list/AVLTREE
  3549.  
  3550. OUTPUTS
  3551.  
  3552.  
  3553. RESULT
  3554.       All interested parties are informed of the change.
  3555.  
  3556. BUGS
  3557.       none known.
  3558.  
  3559. NOTES
  3560.  
  3561. SEE ALSO
  3562.       AddWatcherNode()
  3563.       AddClassWatcher()
  3564.